Skip to content

Commit 176e818

Browse files
committed
Better docs
1 parent 88ef3e4 commit 176e818

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

dbump.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,31 @@ type Config struct {
4747

4848
// Migrator represents database over which we will run migrations.
4949
type Migrator interface {
50-
Init(ctx context.Context) error
50+
// LockDB to prevent running other migrators at the same time.
5151
LockDB(ctx context.Context) error
52+
// UnlockDB to allow running other migrators later.
5253
UnlockDB(ctx context.Context) error
54+
// Init the dbump database where database state is saved.
55+
// What is created by this method completely depends on migrator implementation
56+
// and might be different between databases.
57+
Init(ctx context.Context) error
5358

59+
// Version of the migration. Used only once in the beginning.
5460
Version(ctx context.Context) (version int, err error)
61+
// SetVersion is run after each migration.
5562
SetVersion(ctx context.Context, version int) error
5663

64+
// Begin the transaction before migration.
65+
// Might be no-op if DisableTx is set or transaction are not supported by database.
5766
Begin(ctx context.Context) error
67+
// Commit the transaction after migration.
68+
// Might be no-op if DisableTx is set or transaction are not supported by database.
5869
Commit(ctx context.Context) error
70+
// Rollback the transaction on migration fail.
71+
// Might be no-op if DisableTx is set or transaction are not supported by database.
5972
Rollback(ctx context.Context) error
6073

74+
// Exec the given query and params.
6175
Exec(ctx context.Context, query string, args ...interface{}) error
6276
}
6377

0 commit comments

Comments
 (0)