Skip to content

Commit 32c97ef

Browse files
lunnyearl-warren
authored andcommitted
Remove If Exist check on migration for mssql because that syntax required SQL server 2016 (#30894)
Fix #30872 We will assume the database is consistent before executing the migration. So the indexes should exist. Removing `IF EXIST` then is safe enough. --------- Co-authored-by: silverwind <me@silverwind.io> (cherry picked from commit 40de54ece82356b161cdb9cc224ed9004af8ae5d) Conflicts: models/migrations/v1_22/v286.go MSSQL is not supported in Forgejo
1 parent b8f6523 commit 32c97ef

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
-
22
id: 1
3+
user_id: 1
4+
pull_id: 1
35
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d

models/migrations/v1_22/v286_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ func PrepareOldRepository(t *testing.T) (*xorm.Engine, func()) {
1919

2020
type CommitStatus struct {
2121
ID int64
22-
ContextHash string
22+
ContextHash string `xorm:"char(40) index"`
2323
}
2424

2525
type RepoArchiver struct {
2626
ID int64
27-
RepoID int64
28-
Type int
29-
CommitID string
27+
RepoID int64 `xorm:"index unique(s)"`
28+
Type int `xorm:"unique(s)"`
29+
CommitID string `xorm:"VARCHAR(40) unique(s)"`
3030
}
3131

3232
type ReviewState struct {
3333
ID int64
34-
CommitSHA string
35-
UserID int64
36-
PullID int64
34+
UserID int64 `xorm:"NOT NULL UNIQUE(pull_commit_user)"`
35+
PullID int64 `xorm:"NOT NULL INDEX UNIQUE(pull_commit_user) DEFAULT 0"`
36+
CommitSHA string `xorm:"NOT NULL VARCHAR(40) UNIQUE(pull_commit_user)"`
3737
}
3838

3939
type Comment struct {

0 commit comments

Comments
 (0)