Skip to content

Commit

Permalink
Add Init method
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Jun 4, 2022
1 parent 7ab207a commit eeca5c5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const lockNum int64 = 777_777_777

// Migrator represents DB over which we will run migration queries.
type Migrator interface {
Init(ctx context.Context) error
LockDB(ctx context.Context) error
UnlockDB(ctx context.Context) error

Expand Down Expand Up @@ -68,6 +69,9 @@ func loadMigrations(ms []*Migration, err error) ([]*Migration, error) {
}

func runMigration(ctx context.Context, m Migrator, ms []*Migration) error {
if err := m.Init(ctx); err != nil {
return fmt.Errorf("init: %w", err)
}
if err := m.LockDB(ctx); err != nil {
return fmt.Errorf("lock db: %w", err)
}
Expand Down

0 comments on commit eeca5c5

Please sign in to comment.