@@ -95,8 +95,8 @@ func init() {
9595 }
9696}
9797
98- // GetNewEngine returns a new xorm engine from the configuration
99- func GetNewEngine () (* xorm.Engine , error ) {
98+ // NewEngine returns a new xorm engine from the configuration
99+ func NewEngine () (* xorm.Engine , error ) {
100100 connStr , err := setting .DBConnStr ()
101101 if err != nil {
102102 return nil , err
@@ -128,11 +128,11 @@ func syncTables() error {
128128 return x .StoreEngine ("InnoDB" ).Sync2 (tables ... )
129129}
130130
131- // NewInstallTestEngine creates a new xorm.Engine for testing during install
131+ // InitInstallEngineWithMigration creates a new xorm.Engine for testing during install
132132//
133133// This function will cause the basic database schema to be created
134- func NewInstallTestEngine (ctx context.Context , migrateFunc func (* xorm.Engine ) error ) (err error ) {
135- x , err = GetNewEngine ()
134+ func InitInstallEngineWithMigration (ctx context.Context , migrateFunc func (* xorm.Engine ) error ) (err error ) {
135+ x , err = NewEngine ()
136136 if err != nil {
137137 return fmt .Errorf ("failed to connect to database: %w" , err )
138138 }
@@ -160,9 +160,9 @@ func NewInstallTestEngine(ctx context.Context, migrateFunc func(*xorm.Engine) er
160160 return syncTables ()
161161}
162162
163- // SetEngine sets the xorm.Engine
164- func SetEngine () (err error ) {
165- x , err = GetNewEngine ()
163+ // InitEngine sets the xorm.Engine
164+ func InitEngine () (err error ) {
165+ x , err = NewEngine ()
166166 if err != nil {
167167 return fmt .Errorf ("Failed to connect to database: %v" , err )
168168 }
@@ -178,13 +178,13 @@ func SetEngine() (err error) {
178178 return nil
179179}
180180
181- // NewEngine initializes a new xorm.Engine
181+ // InitEngineWithMigration initializes a new xorm.Engine
182182// This function must never call .Sync2() if the provided migration function fails.
183183// When called from the "doctor" command, the migration function is a version check
184184// that prevents the doctor from fixing anything in the database if the migration level
185185// is different from the expected value.
186- func NewEngine (ctx context.Context , migrateFunc func (* xorm.Engine ) error ) (err error ) {
187- if err = SetEngine (); err != nil {
186+ func InitEngineWithMigration (ctx context.Context , migrateFunc func (* xorm.Engine ) error ) (err error ) {
187+ if err = InitEngine (); err != nil {
188188 return err
189189 }
190190
0 commit comments