petitspas/database/migrations/2026_nir_chiffre_not_null.sql
Julien Martin ca98821b3e Merge develop into master (squash): ticket #102 NIR harmonisation
- Backend: DTO NIR 15 car 2A/2B, validation format+clé, warning cohérence
- BDD: nir_chiffre NOT NULL, migration pour bases existantes
- Seeds: 02 nir_chiffre, 03 Marie 2A / Fatima 99
- Frontend: nir_utils, nir_text_field, formulaire pro, mock inscription AM

Made-with: Cursor
2026-02-26 13:55:42 +01:00

17 lines
562 B
PL/PgSQL

-- 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;