refactor(mitglieder): replace legacy status values (passiv/anwärter/ausgetreten/…) with aktiv/kind/jugend/reserve across backend, frontend, and sync
This commit is contained in:
16
backend/src/database/migrations/090_update_status_values.sql
Normal file
16
backend/src/database/migrations/090_update_status_values.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Migration: 090_update_status_values
|
||||
-- Replace old status values with FDISK-aligned values: aktiv, kind, jugend, reserve.
|
||||
-- Old values passiv, ehrenmitglied, jugendfeuerwehr, anwärter, ausgetreten are removed.
|
||||
-- Idempotent: safe to run multiple times.
|
||||
|
||||
-- 1. Drop existing CHECK constraint
|
||||
ALTER TABLE mitglieder_profile DROP CONSTRAINT IF EXISTS mitglieder_profile_status_check;
|
||||
|
||||
-- 2. Migrate existing data
|
||||
UPDATE mitglieder_profile SET status = 'jugend' WHERE status = 'jugendfeuerwehr';
|
||||
UPDATE mitglieder_profile SET status = NULL
|
||||
WHERE status IN ('passiv', 'ehrenmitglied', 'anwärter', 'ausgetreten');
|
||||
|
||||
-- 3. Re-add CHECK with new allowed values (NULL still allowed for profiles without FDISK sync)
|
||||
ALTER TABLE mitglieder_profile ADD CONSTRAINT mitglieder_profile_status_check
|
||||
CHECK (status IS NULL OR status IN ('aktiv', 'kind', 'jugend', 'reserve'));
|
||||
Reference in New Issue
Block a user