grundik / yii-migrate
简单包,用于向项目添加数据库迁移
0.1.5
2021-01-29 12:31 UTC
Requires
- yiisoft/yii: >1.1.6, <2.0
README
简单包,用于向项目添加数据库迁移
安装
-
在 composer.json 中添加:
"require": { "grundik/yii-migrate": "*@dev" }, "repositories": [{ "type": "vcs", "url": "https://github.com/Grundik/yii-migrate.git" }, { "type": "vcs", "url": "https://github.com/yiisoft/yii.git" }] -
运行 composer
composer update
-
创建配置文件
cp vendor/grundik/yii-migrate/config/migrations.php-default config/migrations.php
-
编辑配置文件以满足您的需求:设置数据库凭据、迁移路径
-
运行
- vendor/bin/migrate - 执行迁移;
- vendor/bin/migrate create - 创建新的迁移。
另请参阅:https://yiiframework.cn/doc/guide/1.1/en/database.migration
模块
要使用多个迁移文件夹(例如,用于多个项目模块),请按照示例配置中的说明在 migrations.php 中定义它们。
使用参数 --module=<module_name> 在显式模块中执行操作
vendor/bin/migrate create migration_name --module=module_name
不带参数的迁移将应用所有模块的所有新迁移。
模块迁移按创建顺序应用,无论模块如何。