loevgaard
loevgaard

Reputation: 23

Rollback doctrine:migrations with Deployer

I have a Symfony 3 application where I use deployer to deploy my application. Also I am using Doctrine Migrations to migrate my database.

I use the symfony3 recipe.

When I run dep deploy, deployer migrates my database. However, when I run dep rollback it doesn't rollback the respective doctrine migrations.

I have searched through Google and Stackoverflow to find anybody solving this, but I can't seem to find anybody.

Do you have a good idea?

Upvotes: 2

Views: 2996

Answers (1)

Wouter J
Wouter J

Reputation: 41934

You can use backwards compatible migrations, this way no rollback is needed ever.

As it can result in a messy database, it's often a good idea to clean up the BC layers regularly. For instance:

  1. Deploy B is deployed, it has a migration to not use a full name column, but instead split up in first name and last name. The full name column is still kept to be backwards compatible;
  2. Assume B is unstable: You rollback to A. As there is still a fully working full name column, no migration rollbacks are needed;
  3. Assume B is stable: When deploying Deploy C, a migration should be executed that first makes sure all full name values are split in first name and last name and then remove the full name column completely;
  4. Assume deploy C is unstable: You rollback to B, as they both only use full name, no migration rollbacks are needed.

Upvotes: 2

Related Questions