Files
foundry-core/db/011-canvas-ai-target-location.sql
codex-bot 56b6181598
Foundry Go checks / check (push) Failing after 2m49s
Foundry Go checks / check (pull_request) Failing after 2m41s
Resolve canonical AI targets at their current canvas owner
2026-11-08 01:16:28 +08:00

10 lines
699 B
PL/PgSQL

BEGIN;
-- The frozen board remains the plan origin; result versions belong to the board
-- that actually received the output after any owner-only move.
ALTER TABLE canvas_ai_steps ADD COLUMN applied_board_id uuid;
ALTER TABLE canvas_ai_steps ADD FOREIGN KEY(project,workspace_id,applied_board_id) REFERENCES materials(project,workspace_id,id);
UPDATE canvas_ai_steps SET applied_board_id=board_id WHERE applied_version IS NOT NULL;
CREATE UNIQUE INDEX canvas_ai_canonical_target_busy ON canvas_ai_steps(project,workspace_id,(frozen_input->>'canonical_root'),node_id,(frozen_input->>'target_incarnation'))
WHERE status IN('queued','running') AND frozen_input->>'canonical_root' IS NOT NULL;
COMMIT;