mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 01:16:31 -06:00
Add option in database config to skip migrations for faster startup. (#30146)
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
This commit is contained in:
parent
bfcb8a477d
commit
07aa956667
@ -87,18 +87,20 @@ func (ss *SQLStore) Init() error {
|
||||
x = ss.engine
|
||||
dialect = ss.Dialect
|
||||
|
||||
migrator := migrator.NewMigrator(ss.engine)
|
||||
migrations.AddMigrations(migrator)
|
||||
if !ss.dbCfg.SkipMigrations {
|
||||
migrator := migrator.NewMigrator(ss.engine)
|
||||
migrations.AddMigrations(migrator)
|
||||
|
||||
for _, descriptor := range registry.GetServices() {
|
||||
sc, ok := descriptor.Instance.(registry.DatabaseMigrator)
|
||||
if ok {
|
||||
sc.AddMigration(migrator)
|
||||
for _, descriptor := range registry.GetServices() {
|
||||
sc, ok := descriptor.Instance.(registry.DatabaseMigrator)
|
||||
if ok {
|
||||
sc.AddMigration(migrator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := migrator.Start(); err != nil {
|
||||
return err
|
||||
if err := migrator.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Init repo instances
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user