Skip to content

Commit ea0394c

Browse files
Loïc Dacharyrealaravinth
Loïc Dachary
authored andcommitted
foreignreference Type VARCHAR(16) must also be set in migrations
1 parent 53bd977 commit ea0394c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

models/migrations/v211.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"fmt"
9+
10+
"xorm.io/xorm"
11+
)
12+
13+
func createForeignReferenceTable(x *xorm.Engine) error {
14+
type ForeignReference struct {
15+
// RepoID is the first column in all indices. now we only need 2 indices: (repo, local) and (repo, foreign, type)
16+
RepoID int64 `xorm:"UNIQUE(repo_foreign_type) INDEX(repo_local)" `
17+
LocalIndex int64 `xorm:"INDEX(repo_local)"` // the resource key inside Gitea, it can be IssueIndex, or some model ID.
18+
ForeignIndex string `xorm:"INDEX UNIQUE(repo_foreign_type)"`
19+
Type string `xorm:"VARCHAR(16) INDEX UNIQUE(repo_foreign_type)"`
20+
}
21+
22+
if err := x.Sync2(new(ForeignReference)); err != nil {
23+
return fmt.Errorf("Sync2: %v", err)
24+
}
25+
return nil
26+
}

0 commit comments

Comments
 (0)