Support upgrading from old migration table name (#889)

This commit is contained in:
Todd Knight authored and GitHub committed 2021-01-28 14:30:08 -07:00
1 parent 3461dcbd0c
commit 955ae41215
10 files changed
+489 -161

No files matched your search

+5 -1
View File
@@ -15,7 +15,7 @@ import (
// It owns the reporting to the UI any errors.
// Returns a cleanup function which must be called even if an error is returned and
// an error code where a non-zero value indicates an error happened.
func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string) (func(), int) {
func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string, requireFresh bool) (func(), int) {
noop := func() {}
// This database is used to keep an exclusive lock on the database for the
// remainder of the command
@@ -52,6 +52,10 @@ func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string) (func(),
ui.Error(fmt.Errorf("Error getting database state: %w", err).Error())
return unlock, 1
}
if requireFresh && st.InitializationStarted {
ui.Error(base.WrapAtLength("Database has already been initialized. Please use 'boundary database migrate'."))
return unlock, 1
}
if st.Dirty {
ui.Error(base.WrapAtLength("Database is in a bad state. Please revert back to the last known good state."))
return unlock, 1