Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: remove outdated comments and Force from migrationInfo (#9340)

p0ny7ed42951e3b9
diff --git a/backend/migrator/migrator.go b/backend/migrator/migrator.go
index 7674aa17d5..d9f01a028a 100644
--- a/backend/migrator/migrator.go
+++ b/backend/migrator/migrator.go
@@ -257,7 +257,6 @@ func migrate(ctx context.Context, storeInstance *store.Store, metadataDriver dbd
Source: dbdriver.LIBRARY,
Type: dbdriver.Migrate,
Description: fmt.Sprintf("Migrate version %s server version %s with files %s.", pv.version, serverVersion, pv.filename),
- Force: true,
}
if _, _, err := utils.ExecuteMigrationDefault(ctx, ctx, storeInstance, nil, 0, metadataDriver, mi, string(buf), nil, dbdriver.ExecuteOptions{}); err != nil {
return err
@@ -344,7 +343,6 @@ func migrateDev(ctx context.Context, storeInstance *store.Store, metadataDriver
Source: dbdriver.LIBRARY,
Type: dbdriver.Migrate,
Description: fmt.Sprintf("Migrate version %s server version %s with files %s.", m.version, serverVersion, m.filename),
- Force: true,
}
if _, _, err := utils.ExecuteMigrationDefault(ctx, ctx, storeInstance, nil, 0, metadataDriver, mi, m.statement, nil, dbdriver.ExecuteOptions{}); err != nil {
return err
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index 3bc671fdbb..9e5de8ba3b 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -158,10 +158,6 @@ type MigrationInfo struct {
Creator string
// Payload contains JSON-encoded string of VCS push event if the migration is triggered by a VCS push event.
Payload *storepb.InstanceChangeHistoryPayload
- // Force is used to execute migration disregarding any migration history with PENDING or FAILED status.
- // This applies to BASELINE and MIGRATE types of migrations because most of these migrations are retry-able.
- // We don't use force option for DATA type of migrations yet till there's customer needs.
- Force bool
}
// placeholderRegexp is the regexp for placeholder.
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index 852e033901..5bb1923d6b 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -277,7 +277,6 @@ func (exec *DatabaseCreateExecutor) createInitialSchema(ctx context.Context, dri
Source: db.UI,
Type: db.Migrate,
Description: "Create database",
- Force: true,
}
creator, err := exec.store.GetUserByID(ctx, task.CreatorID)
if err != nil {
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index a3b8f72733..902a9cca65 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -169,13 +169,6 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile config.P
if mi.Type != db.Baseline && mi.Type != db.MigrateSDL && statement == "" {
return nil, errors.Errorf("empty statement")
}
- // We will force migration for baseline, migrate and data type of migrations.
- // This usually happens when the previous attempt fails and the client retries the migration.
- // We also force migration for VCS migrations, which is usually a modified file to correct a former wrong migration commit.
- if mi.Type == db.Baseline || mi.Type == db.Migrate || mi.Type == db.MigrateSDL || mi.Type == db.Data {
- mi.Force = true
- }
-
return mi, nil
}
diff --git a/backend/utils/utils.go b/backend/utils/utils.go
index 7b11d92f0f..104085a11a 100644
--- a/backend/utils/utils.go
+++ b/backend/utils/utils.go
@@ -352,25 +352,16 @@ func BeginMigration(ctx context.Context, stores *store.Store, m *db.MigrationInf
err := errors.Errorf("database %q version %s migration is already in progress", m.Database, m.Version.Version)
slog.Debug(err.Error())
// For force migration, we will ignore the existing migration history and continue to migration.
- if m.Force {
- return migrationHistory.UID, nil
- }
- return "", common.Wrap(err, common.MigrationPending)
+ return migrationHistory.UID, nil
case db.Failed:
err := errors.Errorf("database %q version %s migration has failed, please check your database to make sure things are fine and then start a new migration using a new version ", m.Database, m.Version.Version)
slog.Debug(err.Error())
// For force migration, we will ignore the existing migration history and continue to migration.
- if m.Force {
- return migrationHistory.UID, nil
- }
- return "", common.Wrap(err, common.MigrationFailed)
+ return migrationHistory.UID, nil
}
}
// Phase 2 - Record migration history as PENDING.
- // MySQL runs DDL in its own transaction, so we can't commit migration history together with DDL in a single transaction.
- // Thus we sort of doing a 2-phase commit, where we first write a PENDING migration record, and after migration completes, we then
- // update the record to DONE together with the updated schema.
statementRecord, _ := common.TruncateString(statement, common.MaxSheetSize)
insertedID, err := stores.CreatePendingInstanceChangeHistory(ctx, prevSchema, m, statementRecord, sheetID)
if err != nil {