commit
db49e14f3d
@ -91,6 +91,9 @@ func Init() {
|
|||||||
if e != nil {
|
if e != nil {
|
||||||
panic(e)
|
panic(e)
|
||||||
}
|
}
|
||||||
|
if len(i) == 0 || strings.TrimSpace(string(i)) == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if strings.Contains(path, "data") {
|
if strings.Contains(path, "data") {
|
||||||
Instance.TablesInitData[tableName] = string(i)
|
Instance.TablesInitData[tableName] = string(i)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -68,6 +68,9 @@ func checkTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for tableName, createSQL := range config.Instance.Tables {
|
for tableName, createSQL := range config.Instance.Tables {
|
||||||
|
if createSQL == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, ok := existTable[tableName]; !ok {
|
if _, ok := existTable[tableName]; !ok {
|
||||||
_, err = Instance.Exec(createSQL)
|
_, err = Instance.Exec(createSQL)
|
||||||
log.Infof("Create Table: %s", createSQL)
|
log.Infof("Create Table: %s", createSQL)
|
||||||
@ -76,10 +79,12 @@ func checkTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if initData, ok := config.Instance.TablesInitData[tableName]; ok {
|
if initData, ok := config.Instance.TablesInitData[tableName]; ok {
|
||||||
_, err = Instance.Exec(initData)
|
if initData != "" {
|
||||||
log.Infof("Init Table: %s", initData)
|
_, err = Instance.Exec(initData)
|
||||||
if err != nil {
|
log.Infof("Init Table: %s", initData)
|
||||||
panic(err)
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user