From eeca5c5733cad4c04dd1fc307a970f1953fd8f82 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Sat, 4 Jun 2022 13:03:31 +0200 Subject: [PATCH] Add Init method --- dbump.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbump.go b/dbump.go index d9a762b..424e572 100644 --- a/dbump.go +++ b/dbump.go @@ -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 @@ -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) }