@@ -95,8 +95,8 @@ func init() {
95
95
}
96
96
}
97
97
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 ) {
100
100
connStr , err := setting .DBConnStr ()
101
101
if err != nil {
102
102
return nil , err
@@ -128,11 +128,11 @@ func syncTables() error {
128
128
return x .StoreEngine ("InnoDB" ).Sync2 (tables ... )
129
129
}
130
130
131
- // NewInstallTestEngine creates a new xorm.Engine for testing during install
131
+ // InitInstallEngineWithMigration creates a new xorm.Engine for testing during install
132
132
//
133
133
// 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 ()
136
136
if err != nil {
137
137
return fmt .Errorf ("failed to connect to database: %w" , err )
138
138
}
@@ -160,9 +160,9 @@ func NewInstallTestEngine(ctx context.Context, migrateFunc func(*xorm.Engine) er
160
160
return syncTables ()
161
161
}
162
162
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 ()
166
166
if err != nil {
167
167
return fmt .Errorf ("Failed to connect to database: %v" , err )
168
168
}
@@ -178,13 +178,13 @@ func SetEngine() (err error) {
178
178
return nil
179
179
}
180
180
181
- // NewEngine initializes a new xorm.Engine
181
+ // InitEngineWithMigration initializes a new xorm.Engine
182
182
// This function must never call .Sync2() if the provided migration function fails.
183
183
// When called from the "doctor" command, the migration function is a version check
184
184
// that prevents the doctor from fixing anything in the database if the migration level
185
185
// 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 {
188
188
return err
189
189
}
190
190
0 commit comments