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
Add a "clean" command to remove **MISSING** migrations from the phinxlog table #206
Comments
I seem to run into this problem too. Problem is I added a migration with |
hi guys you should never delete a migration file after you run it. I would suggest you keep all files in the migrations directory for the life of your project otherwise other developers etc, can never accurately setup the project, see history/design decisions etc. |
What if you're in development mode? What if you're just trying something On Tuesday, April 22, 2014, Rob Morgan notifications@github.com wrote:
Sincerely, |
@robmorgan There is a very valid case for that. You don't want to delete migration files, but when you switch a branch this how it all looks like. I am often removing some entries from |
@hkdobrev , that's exactly what happened to me! |
If you're doing some local development, and you decide you don't want a change before committing it, you should be able to back out of that change without pushing it publicly and having it run in production. Almost needs some sort of "reapply" which would "rollback" and then "migrate" again, because often I am changing a migration before committing it, and manually running those two steps to "reapply". |
ok guys I can see some valid points here. for those that are testing migrations, you can simply |
I think you mean git checkout. And no that won't work because in the I like the idea of "reapply", but I can see a use case for "clean". I'm just brainstorming, really. Maybe "clean" is sufficient? On Thursday, April 24, 2014, Rob Morgan notifications@github.com wrote:
Sincerely, |
What about separate databases per git branch?????? On Thursday, April 24, 2014, Mahmoud Saada mahmoudsaada@gmail.com wrote:
Sincerely, |
@saada In some cases (like mine) separate databases per git branch are not affordable since some dbs are very big (a few gigabytes at least). |
this may help:
|
I've also been having troubles with switching branch to one where newer migrations do not exist. I need to rollback the migrations to the state of the branch I've switched to. Has anyone got a solution for this? All I can think of is that it'd need to store the 'down' SQL into the migrations table every time you migrate up. That way, when the migration files disappear, we can figure out which migrations are missing (from the database table) and run the 'down' SQL in order. My use case is that I'm switching between branches that are further along than other branches, and I'd like to rollback automatically for the branch that I've changed to. |
whatever we do, it should perhaps be designed with git hooks in mind. Things like post-checkout so that phinx can run the proper commands automagically. We'd have to do some diffing between migrations in previous branch vs current branch and then do like @joelperry93 mentioned. Rollback any missing migrations in current branch vs previous branch. |
I'm proposing a "phinx clean" command that would basically find and remove all MISSING migrations from the
phinxlog
table. This happens when you delete a migration FILE after it was added to the database.The text was updated successfully, but these errors were encountered: