Code Monkey home page Code Monkey logo

ezpublish-migrations-bundle's Introduction

eZ Publish 5 Migrations

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.

Installation

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(),
    );
}

Configuration

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
ezpublish_migrations:
    dir_name: %kernel.root_dir%/EzPublishMigrations
    namespace: Application\Migrations
    table_name: ezmigration_versions
    name: Application Migrations
    ez_user: admin

Usage

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

ezpublish:migrations
  :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:

$this->changeMigrationUser('another_username');

and restore the default Migration user by using:

$this->restoreDefaultMigrationUser();

Usage examples

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

Caveats

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'");
}

Acknowledgments

ezpublish-migrations-bundle's People

Contributors

jeromegamez avatar pborreli avatar

Watchers

Matthias Krieft avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.