mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user