arakaki-yuji/mig
Composer 安装命令:
composer require arakaki-yuji/mig
包简介
Simple SQL migration.
README 文档
README
Mig is a simple migration tool for SQL scripts, created by php.
It was tested by only MySQL.
Quickstart
Install mig by composer global
$ composer global require arakaki-yuji/mig
add execution path for composer to $PATH.
$ export PATH=$PATH:$HOME/.composer/vendor/bin
Set mig.config.php to project root directory.
<?php return [ 'db_dsn' => '', // example: mysql:host=localhost:3306;dbname=project_db; 'db_username' => '', 'db_passwd' => '', 'migration_filepath' => 'migrations' // directory for place SQL scripts. ];
Run init command. it create migrations table.
$ mig-cli init
Create SQL scripts for migration.
$ mig-cli create create_user_table Create a new migration file. ================= create migrations/20180907025457_create_user_table.up.sql create migrations/20180907025457_create_user_table.down.sql
Add SQL scripts like the below to migrations/20180907025457_create_user_table.up.sql.
CREATE TABLE IF NOT EXISTS user(id BIGINT);
Add SQL scripts like the below to migrations/20180907025457_create_user_table.down.sql.
DROP TABLE IF EXISTS user;
Apply pending migrations.
$ mig-cli migrate Start migration. ================= Migrate migrations/20180907025457_create_user_table.up.sql
Rollback the latest migration applied.
$ mig-cli rollback Rollback a migration. ====================== Rollback migrations/20180907025457_create_user_table.down.sql
Set config values by environment values
if you want to set config values by environment values, you can do it.
$ MIG_DB_DSN="mysql:host=127.0.0.1:3306;dbname=migrationdbname;" MIG_DB_USERNAME="admin" MIG_DB_PASSWD="password" MIG_MIGRATION_FILEPATH="migrations" mig-cli migrate Start migration. ================= Migrate migrations/20180907025457_create_user_table.up.sql
统计信息
- 总下载量: 87
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-21