可以使用EdgeRecover环境变量指示恢复数据库

This commit is contained in:
GoEdgeLab
2022-09-07 14:44:36 +08:00
parent 390d42c5d9
commit 4074648bf1
3 changed files with 27 additions and 7 deletions

View File

@@ -71,6 +71,14 @@ func (this *IPListDB) init() error {
this.db = db
// 恢复数据库
var recoverEnv, _ = os.LookupEnv("EdgeRecover")
if len(recoverEnv) > 0 {
for _, indexName := range []string{"ip_list_itemId", "ip_list_expiredAt"} {
_, _ = db.Exec(`REINDEX "` + indexName + `"`)
}
}
// 初始化数据库
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS "` + this.itemTableName + `" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,