Commit 07aa9566 by Tom Wilkie Committed by GitHub

Add option in database config to skip migrations for faster startup. (#30146)

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
parent bfcb8a47
......@@ -87,6 +87,7 @@ func (ss *SQLStore) Init() error {
x = ss.engine
dialect = ss.Dialect
if !ss.dbCfg.SkipMigrations {
migrator := migrator.NewMigrator(ss.engine)
migrations.AddMigrations(migrator)
......@@ -100,6 +101,7 @@ func (ss *SQLStore) Init() error {
if err := migrator.Start(); err != nil {
return err
}
}
// Init repo instances
annotations.SetRepository(&SQLAnnotationRepo{})
......@@ -388,6 +390,7 @@ func (ss *SQLStore) readConfig() {
ss.dbCfg.Path = sec.Key("path").MustString("data/grafana.db")
ss.dbCfg.CacheMode = sec.Key("cache_mode").MustString("private")
ss.dbCfg.SkipMigrations = sec.Key("skip_migrations").MustBool()
}
// ITestDB is an interface of arguments for testing db
......@@ -525,4 +528,5 @@ type DatabaseConfig struct {
ConnMaxLifetime int
CacheMode string
UrlQueryParams map[string][]string
SkipMigrations bool
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment