马会东的博客

马会东的博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

一 使用

第一步 安装
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() 中使用

posted on 2018-01-23 15:30  马会东  阅读(1138)  评论(0编辑  收藏  举报