Files
story/migrations/000068_device_account_binding.down.sql
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

19 lines
916 B
PL/PgSQL

BEGIN;
-- Do not silently discard ownership when rolling back.
DO $$ BEGIN
IF EXISTS(SELECT 1 FROM device_account_binding) THEN
RAISE EXCEPTION 'Account device bindings exist; restore the matching backup instead of dropping ownership';
END IF;
END $$;
DROP TRIGGER device_account_binding_reset ON device;
DROP FUNCTION reset_device_account_binding();
DROP TRIGGER device_account_assignment_finish ON device_binding;
DROP FUNCTION finish_device_account_assignment();
DROP TRIGGER device_account_assignment_guard ON device_binding;
DROP FUNCTION guard_device_account_assignment();
DELETE FROM device_ble_binding WHERE subject_id IS NULL;
ALTER TABLE device_ble_binding DROP CONSTRAINT device_ble_binding_profile_pair, DROP COLUMN account_binding_id;
ALTER TABLE device_ble_binding ALTER COLUMN household_id SET NOT NULL, ALTER COLUMN subject_id SET NOT NULL;
DROP TABLE device_account_binding;
COMMIT;