cloud/bmdb: always setup default migration source, even if we're not migrating on startup
Change-Id: I05501d1d04e7c19e766dad9cad84b62ad9571618
Reviewed-on: https://review.monogon.dev/c/monogon/+/1136
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/cloud/bmaas/bmdb/connection.go b/cloud/bmaas/bmdb/connection.go
index acf226f..17d7598 100644
--- a/cloud/bmaas/bmdb/connection.go
+++ b/cloud/bmaas/bmdb/connection.go
@@ -17,15 +17,15 @@
// Connections manage an underlying CockroachDB connection pool, which performs
// required reconnects and connection pooling automatically).
func (b *BMDB) Open(migrate bool) (*Connection, error) {
- if migrate {
- if b.Config.Database.Migrations == nil {
- klog.Infof("Using default migrations source.")
- m, err := model.MigrationsSource()
- if err != nil {
- klog.Exitf("failed to prepare migrations source: %w", err)
- }
- b.Config.Database.Migrations = m
+ if b.Config.Database.Migrations == nil {
+ klog.Infof("Using default migrations source.")
+ m, err := model.MigrationsSource()
+ if err != nil {
+ klog.Exitf("failed to prepare migrations source: %w", err)
}
+ b.Config.Database.Migrations = m
+ }
+ if migrate {
if err := b.Database.MigrateUp(); err != nil {
return nil, fmt.Errorf("migration failed: %w", err)
}