Feat: execute database script to calibrate user storage

This commit is contained in:
HFO4
2020-12-06 16:49:49 +08:00
parent 6486e8799b
commit f7c8039116
5 changed files with 91 additions and 3 deletions

18
bootstrap/script.go Normal file
View File

@ -0,0 +1,18 @@
package bootstrap
import (
"context"
"github.com/cloudreve/Cloudreve/v3/models/scripts"
"github.com/cloudreve/Cloudreve/v3/pkg/util"
)
func RunScript(name string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if err := scripts.RunDBScript(name, ctx); err != nil {
util.Log().Error("数据库脚本执行失败: %s", err)
return
}
util.Log().Info("数据库脚本 [%s] 执行完毕", name)
}