fix: harden sync database contracts
This commit is contained in:
parent
991a068750
commit
94308e9e5c
2 changed files with 34 additions and 0 deletions
16
migrations/0012_sync_contract_hardening.down.sql
Normal file
16
migrations/0012_sync_contract_hardening.down.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
ALTER TABLE staff_sync_command_inbox
|
||||
DROP CONSTRAINT IF EXISTS staff_sync_command_inbox_correlation_id_check,
|
||||
DROP CONSTRAINT IF EXISTS staff_sync_command_inbox_causation_id_check;
|
||||
|
||||
ALTER TABLE staff_sync_command_inbox
|
||||
ALTER COLUMN correlation_id TYPE VARCHAR(36),
|
||||
ALTER COLUMN causation_id TYPE VARCHAR(36);
|
||||
|
||||
ALTER TABLE staff_sync_devices
|
||||
DROP CONSTRAINT IF EXISTS staff_sync_devices_tenant_id_org_unit_id_fkey;
|
||||
|
||||
ALTER TABLE staff_sync_devices
|
||||
ADD CONSTRAINT staff_sync_devices_tenant_id_org_unit_id_fkey
|
||||
FOREIGN KEY (tenant_id, org_unit_id)
|
||||
REFERENCES staff_org_units (tenant_id, id)
|
||||
ON DELETE SET NULL;
|
||||
18
migrations/0012_sync_contract_hardening.up.sql
Normal file
18
migrations/0012_sync_contract_hardening.up.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
ALTER TABLE staff_sync_devices
|
||||
DROP CONSTRAINT IF EXISTS staff_sync_devices_tenant_id_org_unit_id_fkey;
|
||||
|
||||
ALTER TABLE staff_sync_devices
|
||||
ADD CONSTRAINT staff_sync_devices_tenant_id_org_unit_id_fkey
|
||||
FOREIGN KEY (tenant_id, org_unit_id)
|
||||
REFERENCES staff_org_units (tenant_id, id)
|
||||
ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE staff_sync_command_inbox
|
||||
ALTER COLUMN correlation_id TYPE VARCHAR(26),
|
||||
ALTER COLUMN causation_id TYPE VARCHAR(26);
|
||||
|
||||
ALTER TABLE staff_sync_command_inbox
|
||||
ADD CONSTRAINT staff_sync_command_inbox_correlation_id_check
|
||||
CHECK (correlation_id ~ '^[0-9A-HJKMNP-TV-Z]{26}$'),
|
||||
ADD CONSTRAINT staff_sync_command_inbox_causation_id_check
|
||||
CHECK (causation_id IS NULL OR causation_id ~ '^[0-9A-HJKMNP-TV-Z]{26}$');
|
||||
Loading…
Reference in a new issue