Workflow for managing schema changes with Doctrine2

442 Views Asked by At

During development, I run Doctrine's schema:update command often to sync the database schema to my changing entity definitions. Once I'm ready to commit a feature, I want to roll up all the changes into a migration class which I can commit to git.

The problem is that in order to run migrations:diff I need to roll back the database schema to its state before I started messing with schema:update. Doing schema:drop then migrations:migrate is no good because dropping the schema doesn't drop the migration_versions table. That means I have to go into MySQL and manually drop all databases before running the existing migrations and creating the new one.

It works but it feels like I'm doing it wrong. Any better ideas?

1

There are 1 best solutions below

1
On

I do not know 100% correct answer to the question, but there was one option. Every time you need to run schema:update --force first dump sql with schema:update --dump-sql and store it. Then, the need to rollback base is not necessary