db-migrate / db-migrate/node-db-migrate
Store migrations in the database, for independent rollback
- Dominant language
- JavaScript
- Stars
- 2.3k
- Forks
- 361
- PR merge metrics
- No merged PRs in 30d
Description
## I'm submitting a...
- [ ] Bug report
- [X] Feature request
- [ ] Question
Hello.
I've ran into a little problem while developing my app which relies on db-migrate for migrations.
I currently have a master branch with my app's current DB structure, and have started developing a new feature which requires a migration file. I created it along with the down migration, and started doing dev. A user told me about a bug with the current branch, so I switched back to it. However, I couldn't start my app since it relies still on the "feature" migration I did earlier. I tried a `db-migrate down` but then it couldn't find the migration file, which is normal since it's on the feature branch, not on the current one. I thus had to checkout my feature branch again, apply the down migration, and re checkout my current branch.
I believe there could be an easy way to fix this kind of behavior :
- I run `db-migrate sync all` and unless I'm mistaken, I think it should check if a migration with the same name still exists on the filesystem and "down" it if it doesn't anymore (thus allowing switching from branch to branch on a project to be much easier.)
- I looked at the migrations table and it only stores a filename for the migration. Since the filename may not exist anymore when switching branches, I believe one fix for this would be to store the contents of the up and down migration files in database, thus allowing db-migrate to retrieve the queries to run if the file doesn't exist anymore.
That would be a nice feature addition, I believe :)
Thanks for your hard work, db-migrate is a really helpful tool.
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/70853339-store-migrations-in-the-database-for-independent-rollback?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github).
Contributor guide
Assessment
This issue has not been assessed yet.