From 92f1a112f5bbf8c21e3c63d81da296b65207faca Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 8 Apr 2026 11:55:04 +0200 Subject: [PATCH] feat(migration): V22 add title, person_type, nullable first_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../V22__person_type_title_nullable_firstname.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V22__person_type_title_nullable_firstname.sql 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;