MikeSorokin / migration
Phinx 的迁移生成器
0.2.0
2016-09-20 15:18 UTC
Requires
- php: ^5.6 || ^7.0
- robmorgan/phinx: ^0.6.2
- symfony/console: ^3.1
Requires (Dev)
- phpunit/phpunit: ^5.4.0
This package is not auto-updated.
Last update: 2024-09-28 19:47:19 UTC
README
Phinx 迁移构建器。
目前,Phinx(一个迁移库)不能自动生成迁移。Phinx "只"会生成一个包含 up 和 down 函数的空类。你仍然需要手动编写迁移。
实际上,你很少需要手动编写迁移,因为迁移库 "应该"通过比较你的模式映射信息(即你的数据库应该是什么样子)与你的实际当前数据库结构来自动生成迁移类。
生成的迁移
这是一个开发预览 - 不要在生产环境中使用!
功能
- 框架无关
- DBMS:MySQL
- 数据库:字符集,校对规则
- 表:创建,更新,删除,引擎,注释,字符集,校对规则
- 列:创建,更新,删除
- 索引:创建,删除
- 外键(实验性):创建,删除
不支持
- MySQL [double] 不受 Phinx 支持 cakephp/phinx#498
- MySQL [year] 不受 Phinx 支持。 cakephp/phinx#704 | cakephp/phinx#551
- MySQL [bit] 不受 Phinx 支持。 cakephp/phinx#778
- MySQL 中特殊字符的 enum 值: cakephp/phinx#887
- 约束名称的迁移(目前仅自动生成): cakephp/phinx#823
- MySQL 中特殊字符的注释。
安装
git clone https://github.com/odan/migrations.git
cd migrations
composer install --no-dev
集成
composer require odan/migrations
配置
- 默认配置文件:migrations-config.php
示例
<?php return array( 'dsn' => 'mysql:host=127.0.0.1;dbname=test', 'username' => 'root', 'password' => '', 'options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ), 'schema_file' => __DIR__ . '/schema.php', 'migration_path' => __DIR__ );
用法
生成迁移
cd bin
php migrations.php migration:generate
加载自定义配置文件
php migrations.php migration:generate --config=myconfig.php