如何使用数据迁移
官方文档
本项目中的迁移工具是webman官方推荐的数据库迁移工具,参考文档如下:
安装
bash
composer require robmorgan/phinx
初始化
bash
php vendor/bin/phinx init
配置
初始化后,会在项目根目录生成phinx.php文件, 并配置路径,参考如下
php
return
[
'paths' => [
'migrations' => 'plugin/saiadmin/db/migrations',
'seeds' => 'plugin/saiadmin/db/seeds'
],
'environments' => [
'default_migration_table' => 'phinxlog',
'default_environment' => 'development',
'development' => [
'adapter' => 'mysql',
'host' => 'localhost',
'name' => 'saiadmin',
'user' => 'root',
'pass' => '123456',
'port' => '3306',
'charset' => 'utf8',
]
],
'version_order' => 'creation'
];
迁移命令
bash
php vendor/bin/phinx migrate
回滚命令
bash
php vendor/bin/phinx rollback