cloud/bmaas: test and document upgrades across migrations
Change-Id: I1c405b0f2ecc10331b79d02deb8a63f3b148f502
Reviewed-on: https://review.monogon.dev/c/monogon/+/1566
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/cloud/lib/component/crdb.go b/cloud/lib/component/crdb.go
index 4ba9470..7c9c1a8 100644
--- a/cloud/lib/component/crdb.go
+++ b/cloud/lib/component/crdb.go
@@ -137,7 +137,7 @@
// by this CockroachConfig.
func (d *CockroachConfig) MigrateUp() error {
dsn := d.buildDSN("cockroachdb")
- klog.Infof("Running migrations on %s...", dsn)
+ klog.Infof("Running migrations up...")
m, err := migrate.NewWithSourceInstance("iofs", d.Migrations, dsn)
if err != nil {
return err
@@ -153,6 +153,17 @@
}
}
+func (d *CockroachConfig) MigrateUpToIncluding(ver uint) error {
+ dsn := d.buildDSN("cockroachdb")
+ klog.Infof("Running migrations up to %d...", ver)
+ m, err := migrate.NewWithSourceInstance("iofs", d.Migrations, dsn)
+ if err != nil {
+ return err
+ }
+
+ return m.Migrate(ver)
+}
+
// MigrateDownDangerDanger removes all data from the database by performing a
// full migration down.
//
@@ -171,7 +182,7 @@
return fmt.Errorf("no really, this cannot be run on non-in-memory databases")
}
dsn := d.buildDSN("cockroachdb")
- klog.Infof("Running migrations on %s...", dsn)
+ klog.Infof("Running migrations down...")
m, err := migrate.NewWithSourceInstance("iofs", d.Migrations, dsn)
if err != nil {
return err