H-60: harden Captain migration rollback and concurrency (#10)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
ALTER TABLE agent_bots ADD COLUMN IF NOT EXISTS captain_assistant_id BIGINT;
|
||||
|
||||
-- This data repair and its unique indexes must see a stable snapshot. These
|
||||
-- locks block concurrent writes while allowing reads, so run this migration
|
||||
-- in a maintenance window sized for the deduplication.
|
||||
LOCK TABLE agent_bots, agent_bot_inboxes, captain_inboxes, conversations,
|
||||
agent_bot_presence_events, bot_rules, bot_trigger_configs
|
||||
IN SHARE ROW EXCLUSIVE MODE;
|
||||
|
||||
UPDATE agent_bots
|
||||
SET captain_assistant_id = (config ->> 'assistant_id')::BIGINT
|
||||
WHERE bot_type = 'captain'
|
||||
|
||||
Reference in New Issue
Block a user