gozoro / yii2-sql-migrations
与 sql 文件 ...up.sql 和 ...down.sql 一起工作的迁移控制器。
v1.0.2
2023-10-26 10:24 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.0
README
与 sql 文件 ...up.sql 和 ...down.sql 一起工作的迁移控制器。
安装
composer require gozoro/yii2-sql-migrations
配置
编辑你的 config/console.php
... $config = [ ... 'components' => [ ... ], 'controllerMap' => [ 'migrate' => [ 'class' => 'gozoro\sql_migrations\MigrateController', //'migrationTable' => 'other_migration_table', //'migrationPath' => '@app/other_migration_path', //'db' => 'other_database_name' ], ], ... ]; return $config
使用方法
在你的指定在 migrationPath 中的目录中创建迁移文件。
文件命名示例
- 01_create_table.up.sql
- 01_create_table.down.sql
- 02_insert_data.up.sql
- 02_insert_data.down.sql
运行迁移
./yii migrate/up
命令
./yii help migrate
DESCRIPTION
Migration tool using sql-files ...up.sql and ...down.sql
File naming example:
- 01_create_table.up.sql
- 01_create_table.down.sql
- 02_insert_data.up.sql
- 02_insert_data.down.sql
To sort files well, you can add as many zeros to the beginning of the file name as needed.
SUB-COMMANDS
- migrate/down Downgrades the application by reverting old migrations.
- migrate/history Displays the migration history.
- migrate/new Displays the un-applied new migrations.
- migrate/redo Redoes the last few migrations.
- migrate/to Upgrades or downgrades till the specified version.
- migrate/up (default) Upgrades the application by applying new migrations.
To see the detailed information about individual sub-commands, enter:
yii help <sub-command>