diff --git a/backend/src/main/resources/db/migration/V22__person_type_title_nullable_firstname.sql b/backend/src/main/resources/db/migration/V22__person_type_title_nullable_firstname.sql new file mode 100644 index 00000000..a01b6373 --- /dev/null +++ b/backend/src/main/resources/db/migration/V22__person_type_title_nullable_firstname.sql @@ -0,0 +1,12 @@ +-- Add title column for honorifics/salutations (Dr., Tante, Frau, etc.) +ALTER TABLE persons ADD COLUMN title VARCHAR(50); + +-- Add person_type column to distinguish persons from institutions/groups. +-- SKIP is intentionally omitted: it exists in the Java enum for parse-time +-- filtering but must never be persisted. The CHECK constraint enforces this. +ALTER TABLE persons ADD COLUMN person_type VARCHAR(20) NOT NULL DEFAULT 'PERSON'; +ALTER TABLE persons ADD CONSTRAINT chk_person_type + CHECK (person_type IN ('PERSON', 'INSTITUTION', 'GROUP', 'UNKNOWN')); + +-- Make first_name nullable for non-person entities (institutions, groups) +ALTER TABLE persons ALTER COLUMN first_name DROP NOT NULL;