You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to add support for getting migrations from various sources. Either directly passed in as strings or built into the binary as an asset using something like go-bindata.
I think doing this the right way would substantially change gomigrate's API though. Here's what I was thinking:
NewMigrator(db, adapter, []Migrations)
This would change to just initializing the struct and wouldn't actually connect to the db
Since it's just initializing you wouldn't need a logger there and you could change the logger field to be a public field allowing users to set it to what the user wants after initialization
MigrationsFromDir("./path/to/migrations")
This would support the current behavior.
MigrationsFromAssets(Asset, AssetDir, "path")
This would allow consumption of migrations built with go-bindata
You could also just construct straight migrations in your go code and pass them in as an array.
Example use cases:
m := []Migrations{
Migration{
Id: 100,
Up: `create table "foo" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL UNIQUE
);`,
Down: `drop table "users";`,
}
migrator := NewMigrator(db, "sqlite3", m)
migrator.Logger = logrus.StandardLogger()
err := migrator.Migrate()
if err != nil {
panic(err)
}
I'd like to add support for getting migrations from various sources. Either directly passed in as strings or built into the binary as an asset using something like go-bindata.
I think doing this the right way would substantially change gomigrate's API though. Here's what I was thinking:
NewMigrator(db, adapter, []Migrations)
MigrationsFromDir("./path/to/migrations")
MigrationsFromAssets(Asset, AssetDir, "path")
You could also just construct straight migrations in your go code and pass them in as an array.
Example use cases:
Since this would be a fairly substantial API change I wanted to see what you thought of the proposal before doing any work on it.
Thoughts?
The text was updated successfully, but these errors were encountered: