Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db): Do not run deployment migrations #2002

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1627,10 +1627,6 @@ func (h *DBHandler) RunCustomMigrations(
if err != nil {
return err
}
err = h.RunCustomMigrationQueuedApplicationVersions(ctx, writeAllQueuedVersionsFun)
if err != nil {
return err
}
err = h.RunCustomMigrationsCommitEvents(ctx, writeAllEventsFun)
if err != nil {
return err
Expand Down Expand Up @@ -2570,40 +2566,6 @@ func (h *DBHandler) needsCommitEventsMigrations(ctx context.Context, transaction
return true, nil
}

func (h *DBHandler) RunCustomMigrationQueuedApplicationVersions(ctx context.Context, writeAllQueuedVersionsFun WriteAllQueuedVersionsFun) error {
span, ctx := tracer.StartSpanFromContext(ctx, "RunCustomMigrationQueuedApplicationVersions")
defer span.Finish()

return h.WithTransaction(ctx, false, func(ctx context.Context, transaction *sql.Tx) error {
needsMigrating, err := h.needsQueuedDeploymentsMigrations(ctx, transaction)
if err != nil {
return err
}
if !needsMigrating {
return nil
}

err = writeAllQueuedVersionsFun(ctx, transaction, h)
if err != nil {
return fmt.Errorf("could not get current queued versions to run custom migrations: %w", err)
}
return nil
})
}

func (h *DBHandler) needsQueuedDeploymentsMigrations(ctx context.Context, transaction *sql.Tx) (bool, error) {
l := logger.FromContext(ctx).Sugar()
allTeamLocksDb, err := h.DBSelectAnyDeploymentAttempt(ctx, transaction)
if err != nil {
return true, err
}
if allTeamLocksDb != nil {
l.Infof("There are already queued deployments in the DB - skipping migrations")
return false, nil
}
return true, nil
}

// NeedsMigrations: Checks if we need migrations for any table.
func (h *DBHandler) NeedsMigrations(ctx context.Context) (bool, error) {
span, ctx := tracer.StartSpanFromContext(ctx, "NeedsMigrations")
Expand All @@ -2618,7 +2580,6 @@ func (h *DBHandler) NeedsMigrations(ctx context.Context) (bool, error) {
(*DBHandler).needsEnvLocksMigrations,
(*DBHandler).needsAppLocksMigrations,
(*DBHandler).needsTeamLocksMigrations,
(*DBHandler).needsQueuedDeploymentsMigrations,
(*DBHandler).needsCommitEventsMigrations,
(*DBHandler).needsEnvironmentsMigrations,
(*DBHandler).needsAllDeploymentsMigrations,
Expand Down
Loading