aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations/v1_22
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-05-11 22:16:09 +0800
committerGitHub <noreply@github.com>2024-05-11 22:16:09 +0800
commit40de54ece82356b161cdb9cc224ed9004af8ae5d (patch)
tree9217385a3ecca8aa9f731dc0c95aa8e038784af8 /models/migrations/v1_22
parent1f3ada47a3ba7ac978fea702e37adcd400245ba1 (diff)
downloadgitea-40de54ece82356b161cdb9cc224ed9004af8ae5d.tar.gz
gitea-40de54ece82356b161cdb9cc224ed9004af8ae5d.zip
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>
Diffstat (limited to 'models/migrations/v1_22')
-rw-r--r--models/migrations/v1_22/v286.go6
-rw-r--r--models/migrations/v1_22/v286_test.go14
2 files changed, 10 insertions, 10 deletions
diff --git a/models/migrations/v1_22/v286.go b/models/migrations/v1_22/v286.go
index f46d494dfe..e11d16f8de 100644
--- a/models/migrations/v1_22/v286.go
+++ b/models/migrations/v1_22/v286.go
@@ -36,9 +36,9 @@ func expandHashReferencesToSha256(x *xorm.Engine) error {
if setting.Database.Type.IsMSSQL() {
// drop indexes that need to be re-created afterwards
droppedIndexes := []string{
- "DROP INDEX IF EXISTS [IDX_commit_status_context_hash] ON [commit_status]",
- "DROP INDEX IF EXISTS [UQE_review_state_pull_commit_user] ON [review_state]",
- "DROP INDEX IF EXISTS [UQE_repo_archiver_s] ON [repo_archiver]",
+ "DROP INDEX [IDX_commit_status_context_hash] ON [commit_status]",
+ "DROP INDEX [UQE_review_state_pull_commit_user] ON [review_state]",
+ "DROP INDEX [UQE_repo_archiver_s] ON [repo_archiver]",
}
for _, s := range droppedIndexes {
_, err := db.Exec(s)
diff --git a/models/migrations/v1_22/v286_test.go b/models/migrations/v1_22/v286_test.go
index 7c353747e3..a19c9396e2 100644
--- a/models/migrations/v1_22/v286_test.go
+++ b/models/migrations/v1_22/v286_test.go
@@ -19,21 +19,21 @@ func PrepareOldRepository(t *testing.T) (*xorm.Engine, func()) {
type CommitStatus struct {
ID int64
- ContextHash string
+ ContextHash string `xorm:"char(40) index"`
}
type RepoArchiver struct {
ID int64
- RepoID int64
- Type int
- CommitID string
+ RepoID int64 `xorm:"index unique(s)"`
+ Type int `xorm:"unique(s)"`
+ CommitID string `xorm:"VARCHAR(40) unique(s)"`
}
type ReviewState struct {
ID int64
- CommitSHA string
- UserID int64
- PullID int64
+ UserID int64 `xorm:"NOT NULL UNIQUE(pull_commit_user)"`
+ PullID int64 `xorm:"NOT NULL INDEX UNIQUE(pull_commit_user) DEFAULT 0"`
+ CommitSHA string `xorm:"NOT NULL VARCHAR(40) UNIQUE(pull_commit_user)"`
}
type Comment struct {