From 176e818a67b33415cc5db0f2a82800e08fbceb89 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Thu, 30 Jun 2022 07:23:26 +0200 Subject: [PATCH] Better docs --- dbump.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dbump.go b/dbump.go index c29b495..bf7b204 100644 --- a/dbump.go +++ b/dbump.go @@ -47,17 +47,31 @@ type Config struct { // Migrator represents database over which we will run migrations. type Migrator interface { - Init(ctx context.Context) error + // LockDB to prevent running other migrators at the same time. LockDB(ctx context.Context) error + // UnlockDB to allow running other migrators later. UnlockDB(ctx context.Context) error + // Init the dbump database where database state is saved. + // What is created by this method completely depends on migrator implementation + // and might be different between databases. + Init(ctx context.Context) error + // Version of the migration. Used only once in the beginning. Version(ctx context.Context) (version int, err error) + // SetVersion is run after each migration. SetVersion(ctx context.Context, version int) error + // Begin the transaction before migration. + // Might be no-op if DisableTx is set or transaction are not supported by database. Begin(ctx context.Context) error + // Commit the transaction after migration. + // Might be no-op if DisableTx is set or transaction are not supported by database. Commit(ctx context.Context) error + // Rollback the transaction on migration fail. + // Might be no-op if DisableTx is set or transaction are not supported by database. Rollback(ctx context.Context) error + // Exec the given query and params. Exec(ctx context.Context, query string, args ...interface{}) error }