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}$');