feat(migration): V22 add title, person_type, nullable first_name

- Add title VARCHAR(50) column
- Add person_type VARCHAR(20) NOT NULL DEFAULT 'PERSON' with CHECK
  constraint (PERSON, INSTITUTION, GROUP, UNKNOWN — SKIP excluded)
- Drop NOT NULL on first_name for non-person entities

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-08 11:55:04 +02:00
parent 9f14648dc3
commit 92f1a112f5

View File

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