mirror of
https://github.com/Jinnrry/PMail.git
synced 2026-04-23 00:17:16 +08:00
@@ -91,6 +91,9 @@ func Init() {
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if len(i) == 0 || strings.TrimSpace(string(i)) == "" {
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(path, "data") {
|
||||
Instance.TablesInitData[tableName] = string(i)
|
||||
} else {
|
||||
|
||||
+9
-4
@@ -68,6 +68,9 @@ func checkTable() {
|
||||
}
|
||||
|
||||
for tableName, createSQL := range config.Instance.Tables {
|
||||
if createSQL == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := existTable[tableName]; !ok {
|
||||
_, err = Instance.Exec(createSQL)
|
||||
log.Infof("Create Table: %s", createSQL)
|
||||
@@ -76,10 +79,12 @@ func checkTable() {
|
||||
}
|
||||
|
||||
if initData, ok := config.Instance.TablesInitData[tableName]; ok {
|
||||
_, err = Instance.Exec(initData)
|
||||
log.Infof("Init Table: %s", initData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if initData != "" {
|
||||
_, err = Instance.Exec(initData)
|
||||
log.Infof("Init Table: %s", initData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user