MikeSorokin/migration

Phinx 的迁移生成器

0.2.0 2016-09-20 15:18 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:47:19 UTC


README

Phinx 迁移构建器。

目前,Phinx(一个迁移库)不能自动生成迁移。Phinx "只"会生成一个包含 up 和 down 函数的空类。你仍然需要手动编写迁移。

实际上,你很少需要手动编写迁移,因为迁移库 "应该"通过比较你的模式映射信息(即你的数据库应该是什么样子)与你的实际当前数据库结构来自动生成迁移类。

Screenshot

生成的迁移

Screenshot 2

这是一个开发预览 - 不要在生产环境中使用!

功能

  • 框架无关
  • DBMS: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