mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 12:14:40 +00:00
20 lines
628 B
SQL
20 lines
628 B
SQL
-- Reverse: drop the SET NULL FK and restore implicit RESTRICT.
|
|
-- Note: pre-existing NULL provider_id rows remain NULL (RESTRICT FK accepts NULL trivially).
|
|
DO $$
|
|
DECLARE
|
|
cname text;
|
|
BEGIN
|
|
SELECT conname INTO cname
|
|
FROM pg_constraint
|
|
WHERE conrelid = 'agent_heartbeats'::regclass
|
|
AND confrelid = 'llm_providers'::regclass
|
|
AND contype = 'f';
|
|
IF cname IS NOT NULL THEN
|
|
EXECUTE format('ALTER TABLE agent_heartbeats DROP CONSTRAINT %I', cname);
|
|
END IF;
|
|
END $$;
|
|
|
|
ALTER TABLE agent_heartbeats
|
|
ADD CONSTRAINT agent_heartbeats_provider_id_fkey
|
|
FOREIGN KEY (provider_id) REFERENCES llm_providers(id);
|