doctrine-ormdoctrine-migrations

How to use doctrine migrations rollup feature on production server?


I have read: https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html

I'm curious about: doctrine:migrations:rollup. I know what it DOES (deletes my migrations, creates a single one with the whole dump of the current db).

But I don't understand how to use it in production:

When I rollup in local dev, push this into my CD-Pipeline, it would fail on production right? Because the dump would be executed above the already made migrations.

Do I have to delete all migration versions manually and just mark the "rolled up"-dump-migration as done in production?


Solution

  • I found this:

    https://github.com/doctrine/migrations/issues/662

    The whole process is several steps:

    1. delete all your migrations in dev
    2. create a new migration with dump-schema in dev
      (I was misled, that the rollup command does this, but it does not)
    3. deploy to production, but without automatic migrations
    4. then use rollup command in PRODUCTION manually. It does delete all versions from the db and inserts only the rollup version (the one with the dumped schema in it)
    5. then commit and push to your continuous delivery tool. The migration will not be executed, because the manually run rollup command has already inserted the dumped schema version.