diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-10-30 22:32:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-30 22:32:11 +0800 |
commit | 63c0dc89ef96a2e38b38aa6cba5e4e8d1d7b9150 (patch) | |
tree | 91da225f6e02bba47fbe5677e18d6617e43aedcd /models/db/engine.go | |
parent | 76a3190b8a988e18a6b5d66dcc7324f04d83342f (diff) | |
download | gitea-63c0dc89ef96a2e38b38aa6cba5e4e8d1d7b9150.tar.gz gitea-63c0dc89ef96a2e38b38aa6cba5e4e8d1d7b9150.zip |
Rename db Engines related functions (#17481)
* Rename db Engines related functions
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/db/engine.go')
-rwxr-xr-x | models/db/engine.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/models/db/engine.go b/models/db/engine.go index bd55aa7a03..411e39a13b 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -95,8 +95,8 @@ func init() { } } -// GetNewEngine returns a new xorm engine from the configuration -func GetNewEngine() (*xorm.Engine, error) { +// NewEngine returns a new xorm engine from the configuration +func NewEngine() (*xorm.Engine, error) { connStr, err := setting.DBConnStr() if err != nil { return nil, err @@ -128,11 +128,11 @@ func syncTables() error { return x.StoreEngine("InnoDB").Sync2(tables...) } -// NewInstallTestEngine creates a new xorm.Engine for testing during install +// InitInstallEngineWithMigration creates a new xorm.Engine for testing during install // // This function will cause the basic database schema to be created -func NewInstallTestEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err error) { - x, err = GetNewEngine() +func InitInstallEngineWithMigration(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err error) { + x, err = NewEngine() if err != nil { return fmt.Errorf("failed to connect to database: %w", err) } @@ -160,9 +160,9 @@ func NewInstallTestEngine(ctx context.Context, migrateFunc func(*xorm.Engine) er return syncTables() } -// SetEngine sets the xorm.Engine -func SetEngine() (err error) { - x, err = GetNewEngine() +// InitEngine sets the xorm.Engine +func InitEngine() (err error) { + x, err = NewEngine() if err != nil { return fmt.Errorf("Failed to connect to database: %v", err) } @@ -178,13 +178,13 @@ func SetEngine() (err error) { return nil } -// NewEngine initializes a new xorm.Engine +// InitEngineWithMigration initializes a new xorm.Engine // This function must never call .Sync2() if the provided migration function fails. // When called from the "doctor" command, the migration function is a version check // that prevents the doctor from fixing anything in the database if the migration level // is different from the expected value. -func NewEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err error) { - if err = SetEngine(); err != nil { +func InitEngineWithMigration(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err error) { + if err = InitEngine(); err != nil { return err } |