diff --git a/server/migrations/131_issue_origin_slack_chat.down.sql b/server/migrations/131_issue_origin_slack_chat.down.sql new file mode 100644 index 000000000..52a45cbe3 --- /dev/null +++ b/server/migrations/131_issue_origin_slack_chat.down.sql @@ -0,0 +1,8 @@ +-- Revert to the pre-slack_chat issue_origin_type_check list. Any existing rows +-- with origin_type='slack_chat' would violate the rolled-back constraint; the +-- down migration assumes the operator has already deleted or relabeled those +-- rows. Kept strict (no DROP NOT VALID dance) to preserve the schema invariant +-- downstream code relies on. Mirrors 111. +ALTER TABLE issue DROP CONSTRAINT IF EXISTS issue_origin_type_check; +ALTER TABLE issue ADD CONSTRAINT issue_origin_type_check + CHECK (origin_type IN ('autopilot', 'quick_create', 'lark_chat')); diff --git a/server/migrations/131_issue_origin_slack_chat.up.sql b/server/migrations/131_issue_origin_slack_chat.up.sql new file mode 100644 index 000000000..bc22c5791 --- /dev/null +++ b/server/migrations/131_issue_origin_slack_chat.up.sql @@ -0,0 +1,10 @@ +-- Extend issue.origin_type to allow the Slack `/issue` command paths (both the +-- message-prefix form and the slash command) to stamp issues with +-- origin_type='slack_chat'. The Slack integration shipped this origin label +-- (originSlackChat) but no migration ever added it to the CHECK list, so every +-- Slack /issue create tripped SQLSTATE 23514 and IssueService.Create failed — +-- surfaced end-to-end by the /issue slash command (MUL-3908). Mirrors 111 +-- (lark_chat), which fixed the identical gap for Lark. +ALTER TABLE issue DROP CONSTRAINT IF EXISTS issue_origin_type_check; +ALTER TABLE issue ADD CONSTRAINT issue_origin_type_check + CHECK (origin_type IN ('autopilot', 'quick_create', 'lark_chat', 'slack_chat'));