Sync: code local unifié

Synchronisation du code source local (fait foi).

Signed-off-by: lions dev Team
This commit is contained in:
dahoud
2026-03-15 16:25:40 +00:00
parent e82dc356f3
commit 75a19988b0
730 changed files with 53599 additions and 13145 deletions

View File

@@ -0,0 +1,44 @@
-- ============================================================
-- V2.1 — Hiérarchie organisations + corrections
-- Auteur: UnionFlow Team | BCEAO/OHADA compliant
-- ============================================================
-- Ajouter la FK propre pour la hiérarchie (remplace le UUID nu)
ALTER TABLE organisations
DROP CONSTRAINT IF EXISTS fk_organisation_parente;
ALTER TABLE organisations
ADD CONSTRAINT fk_organisation_parente
FOREIGN KEY (organisation_parente_id) REFERENCES organisations(id) ON DELETE SET NULL;
-- Nouveaux champs hiérarchie et modules
ALTER TABLE organisations
ADD COLUMN IF NOT EXISTS est_organisation_racine BOOLEAN NOT NULL DEFAULT TRUE,
ADD COLUMN IF NOT EXISTS chemin_hierarchique VARCHAR(2000),
ADD COLUMN IF NOT EXISTS type_organisation_code VARCHAR(50);
-- Élargir la contrainte de type_organisation pour couvrir tous les métiers
ALTER TABLE organisations DROP CONSTRAINT IF EXISTS chk_organisation_type;
ALTER TABLE organisations
ADD CONSTRAINT chk_organisation_type CHECK (type_organisation IN (
'ASSOCIATION','MUTUELLE_EPARGNE_CREDIT','MUTUELLE_SANTE',
'TONTINE','ONG','COOPERATIVE_AGRICOLE','ASSOCIATION_PROFESSIONNELLE',
'ASSOCIATION_COMMUNAUTAIRE','ORGANISATION_RELIGIEUSE',
'FEDERATION','SYNDICAT','LIONS_CLUB','ROTARY_CLUB','AUTRE'
));
-- Règle : organisation sans parent = racine
UPDATE organisations
SET est_organisation_racine = TRUE
WHERE organisation_parente_id IS NULL;
UPDATE organisations
SET est_organisation_racine = FALSE
WHERE organisation_parente_id IS NOT NULL;
-- Index pour les requêtes hiérarchiques
CREATE INDEX IF NOT EXISTS idx_org_racine ON organisations(est_organisation_racine);
CREATE INDEX IF NOT EXISTS idx_org_chemin ON organisations(chemin_hierarchique);
COMMENT ON COLUMN organisations.est_organisation_racine IS 'TRUE si c''est l''organisation mère (souscrit au forfait pour toute la hiérarchie)';
COMMENT ON COLUMN organisations.chemin_hierarchique IS 'Chemin UUID ex: /uuid-racine/uuid-inter/uuid-feuille — requêtes récursives optimisées';