-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations per environment #413
Comments
I kind of have this working because of a local version of mapfs, but that's yikes. |
If I understand correctly, this is specific to using goose as a library? If so, then there could be a callback function like Or, alternatively, you initialize goose and supply it with the set of migration files instead of the default behavior? So, the root issue is you'd like control over which files goose applies at rutime? |
Yes, that would be ideal |
Is it currently possible to skip a specific migration? I can't believe there is no such possibility. This suggestion might help. |
Well I made it like that, but not so nicely integrated. A call out to some filter function might help a lot. |
What do you think about the following feature, when initializing a // SetExcludeVersions returns a new Options value with ExcludeVersions set to the given value.
// ExcludeVersions is a list of migration versions to exclude when reading migrations from
// the filesystem. This is useful for skipping migrations in tests or development.
//
// Default: include all migrations.
func (o Options) SetExcludeVersions(versions []int64) Options {
// ...
} The idea is when creating a excludeVersions := []int64{6, 18, 99}
goose.DefaultOptions().
SetExcludeVersions(excludeVersions)
provider, err := goose.NewProvider(goose.DialectPostgres, db, options) cc @marcelloh Would this have satisfied your requirement, or is a list of filenames more ergonomic? |
I would say that filenames would probably be more flexible, but perhaps the int-versions will do the trick too. |
Add possibility to decide if the upcoming migration should run or be skipped
If goose would run a migration, if could always check a function isAllowedMigration(name, content),
just before it wants to run the migration.
If I could override that function, it would be easy to have migrations that would only run on a certain environment.
That would be very helpful.
Or have a way to feed Goose an array of filenames (instead of embedFS), then I can do the same.
So this is about seeding from the moment there is a table, so if any migrations will update fields, add fields, delete fields, the end-result can be tested (and each developer has the same data-set to begin with.
The text was updated successfully, but these errors were encountered: