Skip to content

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

fix: update sheet ID in the end of migration (#8929)

Danny Xu9e2230c032b9
diff --git a/backend/store/instance_change_history.go b/backend/store/instance_change_history.go
index 568187b4cb..4ccbd1d56d 100644
--- a/backend/store/instance_change_history.go
+++ b/backend/store/instance_change_history.go
@@ -664,6 +664,9 @@ func (s *Store) UpdateInstanceChangeHistory(ctx context.Context, update *UpdateI
if v := update.Schema; v != nil {
set, args = append(set, fmt.Sprintf("schema = $%d", len(args)+1)), append(args, *v)
}
+ if v := update.Sheet; v != nil {
+ set, args = append(set, fmt.Sprintf("sheet_id = $%d", len(args)+1)), append(args, *v)
+ }
if len(set) == 0 {
return nil
}
diff --git a/backend/utils/utils.go b/backend/utils/utils.go
index a3ac5041c0..d32ba21612 100644
--- a/backend/utils/utils.go
+++ b/backend/utils/utils.go
@@ -428,7 +428,7 @@ func ExecuteMigrationWithFunc(ctx context.Context, driverCtx context.Context, s
startedNs := time.Now().UnixNano()
defer func() {
- if err := EndMigration(ctx, s, startedNs, insertedID, updatedSchema, resErr == nil /* isDone */); err != nil {
+ if err := EndMigration(ctx, s, startedNs, insertedID, updatedSchema, sheetID, resErr == nil /* isDone */); err != nil {
slog.Error("Failed to update migration history record",
log.BBError(err),
slog.String("migration_id", migrationHistoryID),
@@ -544,11 +544,13 @@ func BeginMigration(ctx context.Context, stores *store.Store, m *db.MigrationInf
}
// EndMigration updates the migration history record to DONE or FAILED depending on migration is done or not.
-func EndMigration(ctx context.Context, storeInstance *store.Store, startedNs int64, insertedID string, updatedSchema string, isDone bool) error {
+func EndMigration(ctx context.Context, storeInstance *store.Store, startedNs int64, insertedID string, updatedSchema string, sheetID *int, isDone bool) error {
migrationDurationNs := time.Now().UnixNano() - startedNs
update := &store.UpdateInstanceChangeHistoryMessage{
ID: insertedID,
ExecutionDurationNs: &migrationDurationNs,
+ // Update the sheet ID just in case it has been updated.
+ Sheet: sheetID,
}
if isDone {
// Upon success, update the migration history as 'DONE', execution_duration_ns, updated schema.