feat(schema): one migration + domain model for import/precision/identity (Phase 2, #671) #673

Merged
marcel merged 10 commits from feature/671-schema-foundation into docs/import-migration 2026-05-27 10:13:54 +02:00
Showing only changes of commit f6bf7b9f5e - Show all commits

View File

@@ -24,9 +24,12 @@ ALTER TABLE documents ADD CONSTRAINT chk_meta_date_raw_length CHECK (length(meta
ALTER TABLE documents ADD CONSTRAINT chk_sender_text_length CHECK (length(sender_text) <= 10000);
ALTER TABLE documents ADD CONSTRAINT chk_receiver_text_length CHECK (length(receiver_text) <= 10000);
-- Precision enum — added nullable, backfilled, then made NOT NULL (in this order so the
-- backfill can populate existing rows before the constraint is enforced).
ALTER TABLE documents ADD COLUMN meta_date_precision varchar(16);
-- Precision enum — added with a DB default of 'UNKNOWN', backfilled, then made NOT NULL.
-- The DEFAULT serves two purposes: (1) existing rows get 'UNKNOWN' immediately, and
-- (2) raw-SQL inserts that omit the column (test fixtures, ad-hoc data loads) get a sane,
-- CHECK-valid value instead of violating the NOT NULL constraint. JPA saves still set it
-- explicitly via the entity's @Builder.Default = DatePrecision.UNKNOWN.
ALTER TABLE documents ADD COLUMN meta_date_precision varchar(16) DEFAULT 'UNKNOWN';
UPDATE documents
SET meta_date_precision = CASE WHEN meta_date IS NOT NULL THEN 'DAY' ELSE 'UNKNOWN' END;