From a9c6b9e15b32d0de21e5dfd2bd4f1f7cbf08cd92 Mon Sep 17 00:00:00 2001 From: Julien Martin Date: Thu, 26 Feb 2026 12:56:15 +0100 Subject: [PATCH] feat(#102): BDD nir_chiffre NOT NULL + migration pour bases existantes Made-with: Cursor --- database/BDD.sql | 2 +- .../migrations/2026_nir_chiffre_not_null.sql | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2026_nir_chiffre_not_null.sql diff --git a/database/BDD.sql b/database/BDD.sql index 6a26917..46a741e 100644 --- a/database/BDD.sql +++ b/database/BDD.sql @@ -80,7 +80,7 @@ CREATE INDEX idx_utilisateurs_token_creation_mdp CREATE TABLE assistantes_maternelles ( id_utilisateur UUID PRIMARY KEY REFERENCES utilisateurs(id) ON DELETE CASCADE, numero_agrement VARCHAR(50), - nir_chiffre CHAR(15), + nir_chiffre CHAR(15) NOT NULL, nb_max_enfants INT, biographie TEXT, disponible BOOLEAN DEFAULT true, diff --git a/database/migrations/2026_nir_chiffre_not_null.sql b/database/migrations/2026_nir_chiffre_not_null.sql new file mode 100644 index 0000000..0c94d35 --- /dev/null +++ b/database/migrations/2026_nir_chiffre_not_null.sql @@ -0,0 +1,16 @@ +-- Migration : rendre nir_chiffre NOT NULL (ticket #102) +-- À exécuter sur les bases existantes avant déploiement du schéma avec nir_chiffre NOT NULL. +-- Les lignes sans NIR reçoivent un NIR de test valide (format + clé) pour satisfaire la contrainte. + +BEGIN; + +-- Renseigner un NIR de test valide pour toute ligne où nir_chiffre est NULL +UPDATE assistantes_maternelles +SET nir_chiffre = '275119900100102' +WHERE nir_chiffre IS NULL; + +-- Appliquer la contrainte NOT NULL +ALTER TABLE assistantes_maternelles + ALTER COLUMN nir_chiffre SET NOT NULL; + +COMMIT;