Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions db/migrations/20260502000000_drop_chat_connections.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@
-- agent_connections.agent_id is NOT NULL, but chat_connections.template_agent_id
-- was nullable. Skip orphaned rows (no parent agent) — they could not start
-- in the current model anyway.
INSERT INTO public.agent_connections (
id, agent_id, platform, config, settings, metadata,
status, error_message, created_at, updated_at
)
SELECT
id, template_agent_id, platform, config, settings, metadata,
status, error_message, created_at, updated_at
FROM public.chat_connections
WHERE template_agent_id IS NOT NULL
ON CONFLICT (id) DO NOTHING;
-- Guarded by to_regclass: deployments that never had chat_connections
-- (table created with IF NOT EXISTS in 20260429140000 and never used) skip
-- the copy entirely instead of erroring on the missing relation.
DO $$
BEGIN
IF to_regclass('public.chat_connections') IS NOT NULL THEN
INSERT INTO public.agent_connections (
id, agent_id, platform, config, settings, metadata,
status, error_message, created_at, updated_at
)
SELECT
id, template_agent_id, platform, config, settings, metadata,
status, error_message, created_at, updated_at
FROM public.chat_connections
WHERE template_agent_id IS NOT NULL
ON CONFLICT (id) DO NOTHING;
END IF;
END $$;

DROP TABLE IF EXISTS public.chat_connections;

Expand Down
Loading