-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
There is an awesome feature in Symfony and Doctrine/DoctrineMigrations, as well as with Rails migrations. I'll explain my work flow in past projects where I used doctrine to explain a feature I think would be absolutely awesome in flyway and would really give it a huge extra edge. It's great when working with entity/domain driven development. It wouldn't even have to be in core, just a well supported easily includable extension.
For those unfamiliar with these:
Symfony = Spring/Rails/.NET MVC/etc
Doctrine = Hibernate (Very influenced)
Doctrine Migrations = Flyway/Liquibase
Doctrine Migrations from a dev user standpoint is pretty similar to flyway. Create a PHP class and add an up method (a down method also). However, they use a DateTime string on the file to indicate running order. It looks like Version20130417101156.php
Anyways, here is an example workflow:
In a Symfony app, I would create an entity, add some properties with the appropriate annotations such as for marking M:N relationships etc.
Then, I would use the Symfony "console" like so:
./app/console doctrine:migrations:diff
This would automatically create a migration file. It would do this by running a "diff" between the current DB and the mapping/annotation metadata on the entities. This would work perfectly 95% of the time. You are encouraged to modify the migration file if necessary.
I'm guessing it worked by just capturing the sql that doctrine would generate to create the schema.
I don't know if JPA specifies the api for accessing the sql that would be created from an implementation. If so, that would be great something could be written to cover them all. If not, sucks but gotta start somewhere (I would start with hibernate's api).
Is anyone else interested in something like this? It would be nice to get a group of community members working on something like this. Not everyone would like this type of workflow but for those that do and would, it is a huge time saver. Add properties to classes and avoid creating any files/adding any boilerplate/and writing any sql.