feat(#214): migration Agenda B0 — lots, soft-cancel, prefs
Ajoute agenda_lots versionnés, colonnes soft-cancel / heure / id_lot sur evenements_agenda, soft-cancel + remonte_le sur card_instances, revision_lot sur card_responses, preferences JSONB utilisateurs. Met à jour BDD.sql, ENUMS, verify.sql et entités TypeORM. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+43
-3
@@ -42,7 +42,12 @@ DO $$ BEGIN
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'statut_evenement_agenda_type') THEN
|
||||
CREATE TYPE statut_evenement_agenda_type AS ENUM (
|
||||
'en_attente', 'accepte', 'refuse'
|
||||
'en_attente', 'accepte', 'refuse', 'annule'
|
||||
);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'agenda_lot_statut_type') THEN
|
||||
CREATE TYPE agenda_lot_statut_type AS ENUM (
|
||||
'en_attente', 'accepte', 'refuse', 'annule'
|
||||
);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'statut_validation_type') THEN
|
||||
@@ -109,7 +114,8 @@ CREATE TABLE utilisateurs (
|
||||
ville VARCHAR(150),
|
||||
code_postal VARCHAR(10),
|
||||
profession VARCHAR(150),
|
||||
situation_familiale situation_familiale_type
|
||||
situation_familiale situation_familiale_type,
|
||||
preferences JSONB NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
CREATE INDEX idx_utilisateurs_token_creation_mdp
|
||||
@@ -321,9 +327,31 @@ CREATE TABLE avenants_contrats (
|
||||
modifie_le TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
-- ==========================================================
|
||||
-- Table : agenda_lots (cycles collectifs versionnés — #214)
|
||||
-- ==========================================================
|
||||
CREATE TABLE agenda_lots (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
type type_evenement_agenda_type NOT NULL,
|
||||
statut agenda_lot_statut_type NOT NULL DEFAULT 'en_attente',
|
||||
revision INT NOT NULL DEFAULT 1,
|
||||
soumis_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
verrouille_le TIMESTAMPTZ,
|
||||
refuse_le TIMESTAMPTZ,
|
||||
annule_le TIMESTAMPTZ,
|
||||
annule_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
modifie_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT chk_agenda_lots_revision CHECK (revision >= 1)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_agenda_lots_type_statut ON agenda_lots (type, statut);
|
||||
CREATE INDEX idx_agenda_lots_soumis_le ON agenda_lots (soumis_le);
|
||||
|
||||
-- ==========================================================
|
||||
-- Table : evenements_agenda (vérité métier agenda (absences/congés/arrêt + futurs types))
|
||||
-- 1 ligne = 1 période ; rattachement = placement AM↔enfant (#193)
|
||||
-- 1 ligne = 1 période ; rattachement = placement AM↔enfant (#193 / #214)
|
||||
-- ==========================================================
|
||||
CREATE TABLE evenements_agenda (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
@@ -337,6 +365,12 @@ CREATE TABLE evenements_agenda (
|
||||
cree_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
id_card_instance UUID,
|
||||
motif TEXT,
|
||||
heure TIME,
|
||||
id_lot UUID REFERENCES agenda_lots(id) ON DELETE SET NULL,
|
||||
verrouille_le TIMESTAMPTZ,
|
||||
refuse_le TIMESTAMPTZ,
|
||||
annule_le TIMESTAMPTZ,
|
||||
annule_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
modifie_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT chk_evenements_agenda_dates CHECK (date_fin >= date_debut)
|
||||
@@ -349,6 +383,12 @@ CREATE INDEX idx_evenements_agenda_placement_type_statut
|
||||
CREATE INDEX idx_evenements_agenda_expire_at
|
||||
ON evenements_agenda (expire_at)
|
||||
WHERE statut IN ('en_attente', 'refuse');
|
||||
CREATE INDEX idx_evenements_agenda_id_lot
|
||||
ON evenements_agenda (id_lot)
|
||||
WHERE id_lot IS NOT NULL;
|
||||
CREATE INDEX idx_evenements_agenda_placement_dates_actif
|
||||
ON evenements_agenda (id_placement, date_debut, date_fin)
|
||||
WHERE statut IS DISTINCT FROM 'annule';
|
||||
|
||||
-- ==========================================================
|
||||
-- Table : signalements_bugs
|
||||
|
||||
Reference in New Issue
Block a user