phinx 使用指南

一 使用

第一步 安装
composer require robmorgan/phinx
第二步 初始化
php vendor/robmorgan/phinx/bin/phinx init
创建目录db/migrations
第三步 配置文件
phinx.yml
第四步 创建迁移 文件名驼峰命名
php vendor/robmorgan/phinx/bin/phinx create MyNewMigration


第五步 脚本
...
第六步执行命令
php vendor/robmorgan/phinx/bin/phinx migrate -e localhost

二相关命令
php vendor/robmorgan/phinx/bin/phinx status -e localhost -- 查看状态

php vendor/robmorgan/phinx/bin/phinx migrate -e localhost -t 20180117092422 -- 迁移某(些)脚本

三注意事项:
1 change 方法中创建或者更新表的时候你必须使用 create() 或者 update() 方法;
up方法中使用 save()
2 不能在 change() 方法中使用插入数据,只能在 up() 和 down() 中使用

原文地址:https://www.cnblogs.com/duanweishi/p/8336065.html