From 3824d0f6c35b970096345245b4f5b757ae9e5285 Mon Sep 17 00:00:00 2001 From: Rocky <72559939+hkgood@users.noreply.github.com> Date: Sun, 16 Aug 2026 15:00:10 +0800 Subject: [PATCH] Fix MySQL gateway migration ordering Split replacement-key recreation so MySQL drops the old constraint before validating its reused name. --- .../resources/db/migration/V6__gateway_execution_state.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V6__gateway_execution_state.sql b/src/main/resources/db/migration/V6__gateway_execution_state.sql index c09c8c8..3911f6a 100644 --- a/src/main/resources/db/migration/V6__gateway_execution_state.sql +++ b/src/main/resources/db/migration/V6__gateway_execution_state.sql @@ -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;