From 82dd48ba52c190756a0cfdc94d77e5f49e84e19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B8=D0=BC=D0=B8=D0=BD?= Date: Sun, 3 May 2026 20:45:57 +0300 Subject: [PATCH] fix(migrations): scope check constraint must accept UPPERCASE values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JPA persists enum DataScope as @Enumerated(EnumType.STRING) by default, which writes the enum name verbatim — UPPERCASE. The original CHECK constraint allowed only lowercase ('public','internal','restricted'), making every insert violate it. Drop and recreate constraint with UPPERCASE values to match enum names. Applies to dictionary_definitions.scope and dictionary_records.data_scope. --- .../0008-fix-scope-check-uppercase.xml | 30 +++++++++++++++++++ .../main/resources/db/changelog/master.xml | 1 + 2 files changed, 31 insertions(+) create mode 100644 ordinis-migrations/src/main/resources/db/changelog/changes/0008-fix-scope-check-uppercase.xml diff --git a/ordinis-migrations/src/main/resources/db/changelog/changes/0008-fix-scope-check-uppercase.xml b/ordinis-migrations/src/main/resources/db/changelog/changes/0008-fix-scope-check-uppercase.xml new file mode 100644 index 0000000..6b99cdc --- /dev/null +++ b/ordinis-migrations/src/main/resources/db/changelog/changes/0008-fix-scope-check-uppercase.xml @@ -0,0 +1,30 @@ + + + + + JPA writes enum names UPPERCASE; original constraint accepted only lowercase. Replace. + + ALTER TABLE dictionary_definitions + DROP CONSTRAINT IF EXISTS dictionary_definitions_scope_check; + ALTER TABLE dictionary_definitions + ADD CONSTRAINT dictionary_definitions_scope_check + CHECK (scope IN ('PUBLIC', 'INTERNAL', 'RESTRICTED')); + + + + + Same fix for dictionary_records.data_scope. + + ALTER TABLE dictionary_records + DROP CONSTRAINT IF EXISTS dictionary_records_data_scope_check; + ALTER TABLE dictionary_records + ADD CONSTRAINT dictionary_records_data_scope_check + CHECK (data_scope IN ('PUBLIC', 'INTERNAL', 'RESTRICTED')); + + + + diff --git a/ordinis-migrations/src/main/resources/db/changelog/master.xml b/ordinis-migrations/src/main/resources/db/changelog/master.xml index 2bc6d2a..0bead67 100644 --- a/ordinis-migrations/src/main/resources/db/changelog/master.xml +++ b/ordinis-migrations/src/main/resources/db/changelog/master.xml @@ -12,5 +12,6 @@ +