Fix MySQL gateway migration ordering

Split replacement-key recreation so MySQL drops the old constraint before validating its reused name.
This commit is contained in:
Rocky
2026-08-16 15:00:10 +08:00
parent 41e2145334
commit 3824d0f6c3
@@ -59,7 +59,9 @@ ALTER TABLE usage_records
-- A rotated refresh row points to its replacement. RESTRICT can block the
-- account -> grant -> refresh cascade when an account is deleted.
ALTER TABLE gateway_refresh_tokens
DROP FOREIGN KEY fk_gateway_refresh_replacement,
DROP FOREIGN KEY fk_gateway_refresh_replacement;
ALTER TABLE gateway_refresh_tokens
ADD CONSTRAINT fk_gateway_refresh_replacement
FOREIGN KEY (replaced_by_id) REFERENCES gateway_refresh_tokens (id)
ON DELETE SET NULL;