Le 09/10/2015 dans DevBlog

Make sure your database migrations are complete with Doctrine

A project I’m working on is built with Liquibase: the industry standard for database migrations.

It’s quite new for a large part of my team and it’s not very convenient to work with: for example, to generate a new ChangeSet from the database or from a Doctrine model, we have to copy the whole database, run the updates via Doctrine, and run a liquibase command to compute the diff. Mistakes and oversight are easy.

Compare this to the simple doctrine:migrations:generate and cry.

How to make sure no mistake is done

The point of this article is to explain how you can simply make sure there is never a missing migration, be it from DoctrineMigrationBundle or Liquibase.

Doctrine ship with a convenient doctrine:schema:update command, you can run it and see right away if there is a difference between the database and your entities.

The best part is that you can automate this with a simple phpunit test!

Simple, fast, efficient: that’s how I like it!