gheb / data-migrations-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
❗ ❗
此Bundle曾经很有用,但自从Doctrine Migrations Bundle 2.2以来就不再必要了。请优先使用 doctrine migrations bundle 的多个目录 :)
https://symfony.com.cn/doc/2.2/bundles/DoctrineMigrationsBundle/index.html#configuration
我不会再维护此Bundle了 :) 感谢大家!
DataMigrationsBundle
此Bundle是 Doctrine2 Migrations Bundle 在 Symfony 应用程序中缺失的部分。数据迁移帮助您对数据更改进行版本控制,并以可预测的方式在运行应用程序的每个服务器上应用。
安装
$ composer require gheb/data-migrations-bundle
库位于 vendor/gheb/DataMigrationsBundle
。最后,请确保在 AppKernel.php
中启用此Bundle,方法是在其中包含以下内容
// app/AppKernel.php public function registerBundles() { $bundles = array( //... new Gheb\DataMigrationsBundle\DataMigrationsBundle(), ); }
配置
您可以在 config.yml
中配置路径、命名空间、table_name、name、organize_migrations 和 custom_template。以下示例是默认值。
# 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
使用方法
注意事项
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.
所有迁移功能都包含在几个控制台命令中
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.
文档
此Bundle基于 doctrine migrations bundle。如需更多信息,请参阅 原始Bundle文档。
运行测试 & cs 检查
$ ./vendor/bin/phpunit --bootstrap vendor/autoload.php --testdox tests
$ ./vendor/bin/php-cs-fixer fix --config .php_cs.dist --verbose --dry-run src