11

I am developing a web application using Zend Framework 2 and Doctrine 2. I'm new to Doctrine 2 in general and Migrations in particular. I was wondering if there are any recommended best practices in using this. Some specific things I'm looking for:

  • A recommended workflow from development to deployment?
  • Do you include pre-populating data in migrations?
  • How to handle reverting to a previous version if migration fails.

Many thanks!

stase
  • 111
  • 4
  • 1
    A few months ago I wrote [an answer for the Propel migrations workflow](http://stackoverflow.com/a/28671466/472495). I don't know how widespread my practice is (I made it up myself) - I build the unit test environment from migrations every time the tests are run. It makes for a much greater level of confidence before you run them in non-dev environments. It's not particularly Propel-specific, so maybe that is of interest? – halfer Apr 25 '15 at 21:58

2 Answers2

4

Doctrine has own library for migrations, that includes also Symfony bundle.

For Zend there probably is some bundle as well (maybe seek on Github a bit more)

As for your specific questions:

  1. Nothing special. Basic workflow is nicely described in Symfony bundle documentation. We use it in pretty same way even in a different framework.

  2. Yes, so every developer has fully operational system. For tests we use data-fixtures with minimal required data only.

  3. It's managed by this package itself.

halfer
  • 19,824
  • 17
  • 99
  • 186
Tomas Votruba
  • 23,240
  • 9
  • 79
  • 115
1

The Doctrine ORM module for ZF2 (DoctrineORMModule) has built-in support for Doctrine ORM migrations. There's a very brief blurb in the documentation about how to configure it. You can then access the migration commands (generate, migrate, etc) through the CLI interface that module provides (vendor/bin/doctrine-module)

As for my personal workflow I generally put initialization or pre-population data - the stuff you initially seed a new installation with - into database fixtures (which Doctrine ORM also supports and there is a ZF2 module for).

Adam Lundrigan
  • 598
  • 2
  • 11