gheb/data-migrations-bundle

Migrate your data along side your data structure.

Installs: 1 357

Dependents: 0

Suggesters: 0

Stars: 3

Watchers: 2

Forks: 0

Open Issues: 1

Type:symfony-bundle

v1.3.1 2018-12-04 08:09 UTC

README

License: MIT Build Status

This bundle is the missing piece of the Doctrine2 Migrations bundle into Symfony applications. Data migrations help you version the changes in your data, and apply them in a predictable way on every server running the application.

Installation

$ composer require gheb/data-migrations-bundle

The library can be found at vendor/gheb/DataMigrationsBundle. Finally, be sure to enable the bundle in AppKernel.php by including the following:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        //...
        new Gheb\DataMigrationsBundle\DataMigrationsBundle(),
    );
}

Configuration

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

# app/config/config.yml
data_migrations:
    dir_name: "%kernel.root_dir%/DataMigrations"
    namespace: "App\\Migrations"
    table_name: "data_migration_versions"
    column_name: "version"
    column_length: 14
    executed_at_column_name: "executed_at"
    name: Application Data Migrations
    organize_migrations: false # Possible values are: "BY_YEAR", "BY_YEAR_AND_MONTH", false
    custom_template: ~ # Path to your custom migrations template
    all_or_nothing: false

Usage

Caution

If your application is based on Symfony 3, replace `php app/console` by `php bin/console` before executing any of the console commands included
in this article.

All of the migrations functionality is contained in a few console commands:

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

Documentation

This bundle is based on the doctrine migrations bundle. If you need more information, please refer to the original bundle documentation.

Running tests & quality checks

./vendor/bin/phpunit --bootstrap vendor/autoload.php --testdox tests ./vendor/bin/php-cs-fixer fix --config .php_cs.dist --verbose --dry-run sr