@@ -47,17 +47,31 @@ type Config struct {
47
47
48
48
// Migrator represents database over which we will run migrations.
49
49
type Migrator interface {
50
- Init ( ctx context. Context ) error
50
+ // LockDB to prevent running other migrators at the same time.
51
51
LockDB (ctx context.Context ) error
52
+ // UnlockDB to allow running other migrators later.
52
53
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
53
58
59
+ // Version of the migration. Used only once in the beginning.
54
60
Version (ctx context.Context ) (version int , err error )
61
+ // SetVersion is run after each migration.
55
62
SetVersion (ctx context.Context , version int ) error
56
63
64
+ // Begin the transaction before migration.
65
+ // Might be no-op if DisableTx is set or transaction are not supported by database.
57
66
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.
58
69
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.
59
72
Rollback (ctx context.Context ) error
60
73
74
+ // Exec the given query and params.
61
75
Exec (ctx context.Context , query string , args ... interface {}) error
62
76
}
63
77
0 commit comments