2020-12-06 16:49:49 +08:00
|
|
|
package bootstrap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-11-22 19:53:42 +08:00
|
|
|
"github.com/cloudreve/Cloudreve/v3/models/scripts/invoker"
|
2020-12-06 16:49:49 +08:00
|
|
|
"github.com/cloudreve/Cloudreve/v3/pkg/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func RunScript(name string) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2021-11-22 19:53:42 +08:00
|
|
|
if err := invoker.RunDBScript(name, ctx); err != nil {
|
2022-09-29 17:39:48 +08:00
|
|
|
util.Log().Error("Failed to execute database script: %s", err)
|
2020-12-06 16:49:49 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-09-29 17:39:48 +08:00
|
|
|
util.Log().Info("Finish executing database script %q.", name)
|
2020-12-06 16:49:49 +08:00
|
|
|
}
|