feat(#131): fiches parent/AM éditable, placement AM↔enfant, statuts garde/sans_garde
Squash merge develop → master. - Fiche parent éditable (co-parent, PATCH fiche, GET /parents) - Fiche AM 3 onglets (PATCH fiche, rattacher/détacher enfants) - Table enfants_assistantes_maternelles + enum garde/sans_garde - Migration SQL + BDD.sql canonique - Correctifs recette : @Get() parents, DTO fiche AM, fix NIR Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
-- Ticket #131 / #141 — Placement AM ↔ enfant + statuts garde/sans_garde
|
||||
-- ⚠️ BDD EXISTANTES UNIQUEMENT — ne pas exécuter sur une base créée via BDD.sql à jour.
|
||||
-- Idempotent : safe à rejouer sur recette / prod.
|
||||
|
||||
-- 1) Nouveaux statuts enfant
|
||||
DO $$ BEGIN
|
||||
ALTER TYPE statut_enfant_type ADD VALUE IF NOT EXISTS 'garde';
|
||||
EXCEPTION WHEN duplicate_object THEN NULL;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
ALTER TYPE statut_enfant_type ADD VALUE IF NOT EXISTS 'sans_garde';
|
||||
EXCEPTION WHEN duplicate_object THEN NULL;
|
||||
END $$;
|
||||
|
||||
-- actif → sans_garde (enfants sans placement AM connu au déploiement)
|
||||
UPDATE enfants SET statut = 'sans_garde' WHERE statut = 'actif';
|
||||
|
||||
-- 2) Table de placement AM ↔ enfant
|
||||
CREATE TABLE IF NOT EXISTS enfants_assistantes_maternelles (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
id_am UUID NOT NULL REFERENCES assistantes_maternelles(id_utilisateur) ON DELETE CASCADE,
|
||||
id_enfant UUID NOT NULL REFERENCES enfants(id) ON DELETE CASCADE,
|
||||
date_debut DATE NOT NULL DEFAULT CURRENT_DATE,
|
||||
date_fin DATE NULL,
|
||||
cree_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
cree_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_eam_am ON enfants_assistantes_maternelles(id_am);
|
||||
CREATE INDEX IF NOT EXISTS idx_eam_enfant ON enfants_assistantes_maternelles(id_enfant);
|
||||
|
||||
-- Au plus une garde active par enfant
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_enfant_garde_active
|
||||
ON enfants_assistantes_maternelles (id_enfant)
|
||||
WHERE date_fin IS NULL;
|
||||
Reference in New Issue
Block a user