From d9149d8a0a321f9dbb47e36eee1dcd433b1866d5 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 17 May 2026 18:06:32 +0200 Subject: [PATCH] fix(migrations): preserve unique constraints in v334 sync (#37743) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The truncated `ActionRunner` struct in `AddCancellingSupportToActionRunner` declares only the new `HasCancellingSupport` column. When xorm's `SyncWithOptions` compares it against the live `action_runner` table, every index/constraint absent from the local struct is a candidate for removal. Walking [xorm v1.3.11 sync.go:250-266](https://gitea.com/xorm/xorm/src/tag/v1.3.11/sync.go#L250-L266): - `IndexType` indices skip the drop when `IgnoreIndices || IgnoreDropIndices` — already covered. - `UniqueType` indices skip the drop only when `IgnoreConstrains` — **not** set in #37275, so the existing `UNIQUE` on `token_hash` (and any other uniques) would be dropped on upgrade. Adding `IgnoreConstrains: true` matches v333's pattern and preserves the existing unique constraints. Spotted by @wxiaoguang in https://github.com/go-gitea/gitea/pull/37275#discussion_r3254168680. --- This PR was written with the help of Claude Opus 4.7 Co-authored-by: Claude (Opus 4.7) Co-authored-by: Nicolas --- models/migrations/v1_27/v334.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/migrations/v1_27/v334.go b/models/migrations/v1_27/v334.go index 02237a70ae..111a81e8b0 100644 --- a/models/migrations/v1_27/v334.go +++ b/models/migrations/v1_27/v334.go @@ -11,6 +11,7 @@ func AddCancellingSupportToActionRunner(x *xorm.Engine) error { } _, err := x.SyncWithOptions(xorm.SyncOptions{ + IgnoreConstrains: true, IgnoreDropIndices: true, }, new(ActionRunner)) return err