Skip to content

Commit

Permalink
Merge pull request #342 from cashapp/prudhvi.mdl_lock_name_change
Browse files Browse the repository at this point in the history
Use quoted table name as lock name
  • Loading branch information
prudhvi authored Aug 28, 2024
2 parents 50fab0a + 589a59b commit 31b5fad
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit 31b5fad

Please sign in to comment.