feat: Add CheckSetup function call in main to ensure proper initialization #942
This commit is contained in:
5
main.go
5
main.go
@@ -52,6 +52,9 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
common.FatalLog("failed to initialize database: " + err.Error())
|
common.FatalLog("failed to initialize database: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.CheckSetup()
|
||||||
|
|
||||||
// Initialize SQL Database
|
// Initialize SQL Database
|
||||||
err = model.InitLogDB()
|
err = model.InitLogDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -76,7 +79,7 @@ func main() {
|
|||||||
model.InitOptionMap()
|
model.InitOptionMap()
|
||||||
// Initialize model settings
|
// Initialize model settings
|
||||||
operation_setting.InitModelSettings()
|
operation_setting.InitModelSettings()
|
||||||
|
|
||||||
if common.RedisEnabled {
|
if common.RedisEnabled {
|
||||||
// for compatibility with old versions
|
// for compatibility with old versions
|
||||||
common.MemoryCacheEnabled = true
|
common.MemoryCacheEnabled = true
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func createRootAccountIfNeed() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSetup() {
|
func CheckSetup() {
|
||||||
setup := GetSetup()
|
setup := GetSetup()
|
||||||
if setup == nil {
|
if setup == nil {
|
||||||
// No setup record exists, check if we have a root user
|
// No setup record exists, check if we have a root user
|
||||||
@@ -244,7 +244,6 @@ func migrateDB() error {
|
|||||||
}
|
}
|
||||||
err = DB.AutoMigrate(&Setup{})
|
err = DB.AutoMigrate(&Setup{})
|
||||||
common.SysLog("database migrated")
|
common.SysLog("database migrated")
|
||||||
checkSetup()
|
|
||||||
//err = createRootAccountIfNeed()
|
//err = createRootAccountIfNeed()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user