fix(migrations): scope check constraint must accept UPPERCASE values
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.
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.27.xsd">
|
||||
|
||||
<changeSet id="0008-1-fix-dict-def-scope-uppercase" author="ordinis">
|
||||
<comment>JPA writes enum names UPPERCASE; original constraint accepted only lowercase. Replace.</comment>
|
||||
<sql>
|
||||
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'));
|
||||
</sql>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="0008-2-fix-dict-rec-scope-uppercase" author="ordinis">
|
||||
<comment>Same fix for dictionary_records.data_scope.</comment>
|
||||
<sql>
|
||||
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'));
|
||||
</sql>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -12,5 +12,6 @@
|
||||
<include file="changes/0005-outbox-events.xml"/>
|
||||
<include file="changes/0006-idempotency-keys.xml"/>
|
||||
<include file="changes/0007-add-version-columns.xml"/>
|
||||
<include file="changes/0008-fix-scope-check-uppercase.xml"/>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
Reference in New Issue
Block a user