Просмотр исходного кода

feat: Add CheckSetup function call in main to ensure proper initialization #942

CaIon 11 месяцев назад
Родитель
Сommit
082218173a
2 измененных файлов с 5 добавлено и 3 удалено
  1. 4 1
      main.go
  2. 1 2
      model/main.go

+ 4 - 1
main.go

@@ -52,6 +52,9 @@ func main() {
 	if err != nil {
 		common.FatalLog("failed to initialize database: " + err.Error())
 	}
+
+	model.CheckSetup()
+
 	// Initialize SQL Database
 	err = model.InitLogDB()
 	if err != nil {
@@ -76,7 +79,7 @@ func main() {
 	model.InitOptionMap()
 	// Initialize model settings
 	operation_setting.InitModelSettings()
-	
+
 	if common.RedisEnabled {
 		// for compatibility with old versions
 		common.MemoryCacheEnabled = true

+ 1 - 2
model/main.go

@@ -56,7 +56,7 @@ func createRootAccountIfNeed() error {
 	return nil
 }
 
-func checkSetup() {
+func CheckSetup() {
 	setup := GetSetup()
 	if setup == nil {
 		// No setup record exists, check if we have a root user
@@ -244,7 +244,6 @@ func migrateDB() error {
 	}
 	err = DB.AutoMigrate(&Setup{})
 	common.SysLog("database migrated")
-	checkSetup()
 	//err = createRootAccountIfNeed()
 	return err
 }