数据库AutoMigrate现在是可选的,添加了启动参数

This commit is contained in:
2025-05-21 09:03:20 +08:00
parent 66980958f5
commit 2a408f9cfd
3 changed files with 10 additions and 4 deletions

View File

@@ -33,9 +33,10 @@ func connectSQLite() {
fmt.Printf("error in connecting to SQLite:")
fmt.Println(err)
os.Exit(1)
}
Main.AutoMigrate(&model.Member{}, &model.Tweak{})
if config.InitDB == true {
Main.AutoMigrate(&model.Member{}, &model.Tweak{})
}
}
func connectPGSQL() {
@@ -43,5 +44,7 @@ func connectPGSQL() {
if err != nil {
panic(err)
}
Main.AutoMigrate(&model.Member{}, &model.Tweak{})
if config.InitDB == true {
Main.AutoMigrate(&model.Member{}, &model.Tweak{})
}
}