Skip to content

Commit

Permalink
Use quoted table name as lock name
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvi committed Aug 28, 2024
1 parent 50fab0a commit 589a59b
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 589a59b

Please sign in to comment.