summaryrefslogtreecommitdiffstats
path: root/models/models.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-06-14 10:22:55 +0800
committerGitHub <noreply@github.com>2021-06-14 10:22:55 +0800
commit0393a57511dc863bea4783fbb4b57cd11c41688a (patch)
treef479085c97ffe419e6fe02c88f6a2730a673fcb8 /models/models.go
parenta005265718b840d34858a3b705f8133e1b4dbdbf (diff)
downloadgitea-0393a57511dc863bea4783fbb4b57cd11c41688a.tar.gz
gitea-0393a57511dc863bea4783fbb4b57cd11c41688a.zip
Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599)
* Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index * Fix pull index * Add tests for concurrent creating issues * Fix lint * Fix tests * Fix postgres test * Add test for migration v180 * Rename wrong test file name Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/models/models.go b/models/models.go
index b0a9062566..2b3203ecca 100644
--- a/models/models.go
+++ b/models/models.go
@@ -134,6 +134,7 @@ func init() {
new(ProjectIssue),
new(Session),
new(RepoTransfer),
+ new(IssueIndex),
)
gonicNames := []string{"SSL", "UID"}
@@ -171,6 +172,10 @@ func GetNewEngine() (*xorm.Engine, error) {
return engine, nil
}
+func syncTables() error {
+ return x.StoreEngine("InnoDB").Sync2(tables...)
+}
+
// NewTestEngine sets a new test xorm.Engine
func NewTestEngine() (err error) {
x, err = GetNewEngine()
@@ -181,7 +186,7 @@ func NewTestEngine() (err error) {
x.SetMapper(names.GonicMapper{})
x.SetLogger(NewXORMLogger(!setting.IsProd()))
x.ShowSQL(!setting.IsProd())
- return x.StoreEngine("InnoDB").Sync2(tables...)
+ return syncTables()
}
// SetEngine sets the xorm.Engine
@@ -222,7 +227,7 @@ func NewEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err e
return fmt.Errorf("migrate: %v", err)
}
- if err = x.StoreEngine("InnoDB").Sync2(tables...); err != nil {
+ if err = syncTables(); err != nil {
return fmt.Errorf("sync database struct error: %v", err)
}