Skip to content
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

List migrations #32

Open
maroux opened this issue Mar 5, 2019 · 1 comment
Open

List migrations #32

maroux opened this issue Mar 5, 2019 · 1 comment
Labels

Comments

@maroux
Copy link

maroux commented Mar 5, 2019

There should be a way to list which migrations have been applied, and which are pending. This would be immensely helpful in trying to apply migrations to a real life environment, stage or prod, where you don't want to run queries without knowing what queries would be run. Django provides a good model for this.

Also kinda related is the concept of dry run in the migrate method. In a similar vein as above, dry run would not do any writes to the database, but just list which queries it would've run if you didn't use the dry-run option. Django doesn't support this option, but again this would be really useful is increasing confidence when using this library on live environments such as stage or prod.

Implementation: I'd add a separate function (perhaps ShowMigrations) that lists all migrations with a status of whether they have been applied or not. For dry run, perhaps a new method MigrateWithOptions(options) would be best, so you can extend it in the future without breaking function signature. Migrate method could just be changed with this signature in v2 if that works.

I can take a stab at it if the this sounds reasonable.

@kiyonlin
Copy link

Making func (g *Gormigrate) migrationRan(m *Migration) (bool, error) method accessable is an easy way to reach this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants