Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle doctrine migrations in bundles

I'm developing an application, using Symfony 2.3, which will have to be installed for different customers. We will offer different features so the idea is to have the features/bundles separate from the main app and load the into the project using composer. As we are using Doctrine Migrations to maintain DB changes across versions I'm unsure on how to go about using them from a bundle. We're using Capifony to deploy the app to the live server.

So my question is... how can I automatize the execution of migrations from composer loaded bundles?

like image 674
Michi Avatar asked Oct 25 '13 05:10

Michi


3 Answers

I ended up creating a command that will copy all migration files from predefined directories in bundles to the default location and then executing doctrine:migrations:migrate from within the command.

like image 118
Michi Avatar answered Oct 05 '22 22:10

Michi


For a complex deployment, I used phing. He easily integrate with the Symfony console. But in the end I use of a simple code on the Synfony console. Composer can easily call Symfony app commands as "post-install-cmd"

like image 44
nonlux Avatar answered Oct 06 '22 00:10

nonlux


I don't think "composer loaded bundles" is the issue here. For instance, you could have several bundles in src/ (part of the app or submoduled) and have the exact same problem. The issue is having multiple entity managers and databases for your different bundles. Where they actually reside is trivial.

Anyway, I'm having the exact same problem. After some searching, I discovered there is actually an open pull request to fix this: https://github.com/doctrine/DoctrineMigrationsBundle/pull/46

I'm hoping it gets fixed soon!

like image 44
Nate Avatar answered Oct 05 '22 22:10

Nate