gheb / data-migrations-bundle
Migrate your data along side your data structure.
Fund package maintenance!
gregoirehebert
Installs: 4 622
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1.0
- doctrine/common: ^2.8
- doctrine/dbal: ^2.6
- doctrine/doctrine-bundle: ^1.10
- doctrine/migrations: ^2.2
- doctrine/orm: ^2.6
- symfony/config: ^4.2
- symfony/console: ^4.2
- symfony/dependency-injection: ^4.2.7
- symfony/http-kernel: ^4.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- mikey179/vfsstream: ^1.6
- phpstan/phpstan: ^0.11.19
- phpunit/phpunit: ^7.4 | ^8.0
Suggests
- doctrine/doctrine-migrations-bundle: Help you version the changes in your database schema
README
❗ ❗
This Bundle has been useful, but is not necessary anymore since Doctrine Migrations Bundle 2.2. Prefer using multiple directories from doctrine migrations bundle :)
https://symfony.com/doc/2.2/bundles/DoctrineMigrationsBundle/index.html#configuration
I won't maintain this bundle anymore :) Thank you all !
DataMigrationsBundle
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: "Application\\Migrations" table_name: "data_migration_versions" 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
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 & cs checks
$ ./vendor/bin/phpunit --bootstrap vendor/autoload.php --testdox tests
$ ./vendor/bin/php-cs-fixer fix --config .php_cs.dist --verbose --dry-run src