From 3fdace949269d4f8332f8c7cb4826328a002b929 Mon Sep 17 00:00:00 2001 From: Christ Date: Mon, 17 Aug 2026 21:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20MySQL=20=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E5=A4=96=E9=94=AE=E7=B4=A2=E5=BC=95=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/migrations/mysql/00031_dev_schema_baseline.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/db/migrations/mysql/00031_dev_schema_baseline.sql b/internal/db/migrations/mysql/00031_dev_schema_baseline.sql index 8e9023b..75c7963 100644 --- a/internal/db/migrations/mysql/00031_dev_schema_baseline.sql +++ b/internal/db/migrations/mysql/00031_dev_schema_baseline.sql @@ -48,9 +48,15 @@ CREATE UNIQUE INDEX idx_notification_outbox_channel_idempotency ON notification_outbox(channel_id, idempotency_key); -- +goose Down +-- InnoDB 会让 00021 的 channel_id 外键复用新增的复合索引;先移除外键, +-- 否则删除幂等索引会失败。最后按 00021 的约束名称恢复原始关系。 +ALTER TABLE notification_outbox DROP FOREIGN KEY fk_notification_outbox_channel; DROP INDEX idx_notification_outbox_channel_idempotency ON notification_outbox; ALTER TABLE notification_outbox DROP COLUMN idempotency_key; ALTER TABLE notification_outbox DROP COLUMN uncertain_at; +ALTER TABLE notification_outbox + ADD CONSTRAINT fk_notification_outbox_channel + FOREIGN KEY (channel_id) REFERENCES notification_channels(id) ON DELETE CASCADE; DROP TABLE IF EXISTS security_audit_logs; DROP TABLE IF EXISTS order_refresh_jobs; DROP INDEX idx_orders_cursor ON orders;