So I'm messing around locally and made two migrations with the second having really very minor changes on top of the first one. We agreed as a team, when working on an issue, to keep migrations minimal. So I would like to make one out of these two, before making a comitting my code. My question is, how would I do that? Do I remove them and use make:migration
again and it will generate the correct last updated version in one file instead of two or will I have to do something else?
Asked
Active
Viewed 156 times
-1
-
You'll have to `execute --down` them first or it won't find any changes. – msg Aug 28 '19 at 11:43
-
Wouldn't removing them have the same effect @msg? Like in PHPStorm and in the database migrations table. – Aug 28 '19 at 11:44
-
Can't say for sure, I'm not familiar with PHPStorm, but I'd think not. Does it remove the version from `migration_versions` *and* the fields included in that migration automatically? – msg Aug 28 '19 at 11:51
-
if you remove it from both PHPStorm and the database, then yes, the same thing is achieved. If I achieve that, do I just use make:migration again? – Aug 28 '19 at 11:53
1 Answers
-1
What worked for me:
1- Make a backup of your database (if you have something important that you want to keep that is not in the fixtures, if you have any).
2- Remove both files from PHPStorm and their versions from the migration_versions
table.
3- Do php bin/console doctrine:migrations:migrate
, which will load the migrations up to the point before making any changes.
4- Carry out php bin/console make:migration
to make a migration of the changes you made into 1 file.
5- Carry out php bin/console doctrine:migrations:migrate
again to apply the changes you made.
This works with more than 2 files as well but may not fit every situation, so consider that first.