Migrations for eZ Publish 5

Installs: 259

Dependents: 0

Stars: 12

Watchers: 4

Forks: 3

Open Issues: 1

Language: PHP

1.3 2015-06-10 19:08 UTC


Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality License

Migrations for eZ Publish 5, based on Doctrine Migrations, very similar to Symfony's DoctrineMigrationsBundle.


Follow these steps to install the bundle in your eZ Publish 5 project.

Add the following to your composer.json file:

    "require": {
        "doctrine/migrations": "1.0.0-alpha3",
        "kreait/ezpublish-migrations-bundle": "~1.0"

Update the vendor libraries:

$ php composer.phar update

If everything worked, the EzPublishMigrationsBundle can now be found at vendor/kreait/ezpublish-migrations-bundle.

Finally, be sure to enable the bundle in EzPublishKernel.php by including the following:

// ezpublish/EzPublishKernel.php
public function registerBundles()
    $bundles = array(
        new Kreait\EzPublish\MigrationsBundle\KreaitEzPublishMigrationsBundle(),


You can configure the path, namespace, table_name and name in your config.yml. The examples below are the default values.

// ezpublish/config/config.yml
    dir_name: %kernel.root_dir%/EzPublishMigrations
    namespace: Application\Migrations
    table_name: ezmigration_versions
    name: Application Migrations
    ez_user: admin


All of the migrations functionality is contained in the following commands:

  :execute  Execute a single migration version up or down manually.
  :generate Generate a blank migration class.
  :migrate  Execute a migration to a specified version or the latest available version.
  :status   View the status of a set of migrations.
  :version  Manually add and delete migration versions from the version table.

The usage is identical to Symfony's DoctrineMigrationBundle, except for the missing :diff command. Please have a look at the official documentation for further information.

Changing the current migration user during a migration

You can change the current eZ Publish user inside a migration by issuing the following command:


and restore the default Migration user by using:


Usage examples

See src/Resources/doc/examples for some usage examples.


No "real" SQL statements

When you create a migration using only eZ Publish's API methods, no actual SQL statements are executed. This results in the following message:

Migration was executed but did not result in any SQL statements.

You can avoid this message by adding a dummy SQL statement at the end of your up() and down() method:

public function up(Schema $schema)
    // ...
    $this->addSql("SELECT 'Description of what we did here'");