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

Use quoted table name as lock name #342

Merged
merged 1 commit into from
Aug 28, 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
13 changes: 7 additions & 6 deletions pkg/migration/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,18 @@ func (r *Runner) Run(originalCtx context.Context) error {
return err
}

// Take a metadata lock to prevent other migrations from running concurrently.
r.metadataLock, err = dbconn.NewMetadataLock(ctx, r.dsn(), fmt.Sprintf("spirit_%s_%s", r.migration.Database, r.migration.Table), r.logger)
if err != nil {
return err
}

// Get Table Info
r.table = table.NewTableInfo(r.db, r.migration.Database, r.migration.Table)
if err := r.table.SetInfo(ctx); err != nil {
return err
}

// Take a metadata lock to prevent other migrations from running concurrently.
r.metadataLock, err = dbconn.NewMetadataLock(ctx, r.dsn(), r.table.QuotedName, r.logger)
if err != nil {
return err
}

// This step is technically optional, but first we attempt to
// use MySQL's built-in DDL. This is because it's usually faster
// when it is compatible. If it returns no error, that means it
Expand Down
Loading