-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapt.go
39 lines (34 loc) · 929 Bytes
/
adapt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package adapt
const (
// Version is the package's version string used to store in meta tables
Version = "adapt@v0.2.0"
)
/*
Migrate migrates all available migrations in your SourceCollection against the
Driver, when they weren't already applied before.
Example:
var db *sql.DB = getDB()
err := adapt.Migrate(
"myService@v1.3.12",
adapt.NewMySQLDriver(db,
adapt.MySQLDriverOptionTableName("_auth_migrations"),
adapt.MySQLDriverOptionDisableTx,
),
adapt.SourceCollection{
adapt.NewEmbedFSSource(embedFS, "foo/bar/directory"),
adapt.NewMemoryFSSource(map[string]string{}),
adapt.NewCodeSource("x", adapt.Hook{
MigrateUpTx: func(tx *sql.Tx) error {
return nil
},
}),
},
)
*/
func Migrate(executor string, driver Driver, sources SourceCollection, options ...Option) error {
e, err := newExec(executor, driver, sources, options...)
if err != nil {
return err
}
return e.run()
}