yiiext/migrate-command
Composer 安装命令:
composer require yiiext/migrate-command
包简介
This is an enhanced version of the Yii Database Migration Tool that adds module support and many more usefull features.
README 文档
README
This extension is an enhanced version of the Yii Database Migration Tool that adds module support and many more usefull features. If there is anything you would like to have added, or you found a bug please report it on github or contact me via email.
Features
- Module-Support (migrations are distributed in a seperate folder for every module) so you can...
- ...enable and disable Modules
- ...add new module by migrating it up
- ...remove a module by running its migrations down
- ...select the modules you want to run migrations for in every run
- ...declare Module-dependencies (coming soon)
- ...different migration templates depending on modules (coming soon)
Resources
Requirements
- Yii 1.1.6 or above (MigrateCommand was introduced in this version) if you copy MigrateCommand and CDbMigration you should be able to use this extension with any yii version.
Installation
- Extract the release file under
protected/extensions. - Add the following to your config file for yiic command:
'commandMap' => array( 'migrate' => array( // alias of the path where you extracted the zip file 'class' => 'application.extensions.yiiext.commands.migrate.EMigrateCommand', // this is the path where you want your core application migrations to be created 'migrationPath' => 'application.db.migrations', // the name of the table created in your database to save versioning information 'migrationTable' => 'tbl_migration', // the application migrations are in a pseudo-module called "core" by default 'applicationModuleName' => 'core', // define all available modules (if you do not set this, modules will be set from yii app config) 'modulePaths' => array( 'admin' => 'application.modules.admin.db.migrations', 'user' => 'application.modules.user.db.migrations', 'yourModule' => 'application.any.other.path.possible', // ... ), // you can customize the modules migrations subdirectory which is used when you are using yii module config 'migrationSubPath' => 'migrations', // here you can configure which modules should be active, you can disable a module by adding its name to this array 'disabledModules' => array( 'admin', 'anOtherModule', // ... ), // the name of the application component that should be used to connect to the database 'connectionID'=>'db', // alias of the template file used to create new migrations 'templateFile'=>'application.db.migration_template', ), ),
Please note: if you already used MigrateCommand before, make sure to add the module column to your migrationTable:
ALTER TABLE `tbl_migration` ADD COLUMN `module` varchar(32) DEFAULT NULL; UPDATE `tbl_migration` SET module='core';
Usage
###General Usage
You can run yiic migrate help to see all parameters and a short example on how to use them.
The basics are explained in the Definitive Guide to Yii. Read them first if you haven't used database migration before. The usage of Extended Migration Command is not much different from the native one. The only command that is different is create where you have to additionally specify the modulename:
yiic migrate create modulename create_user_table
This creates a new migration named 'create_user_table' in module 'modulename'. The native usage
yiic migrate create create_user_table
creates a new migration named 'create_user_table' in the application(core).
###--module Parameter
In all other commands (up, down, history, new, to and mark) you can use the parameter --module=<modulenames> where <modulenames> can be a comma seperated list of module names or a single module name. This parameter will limit the current command to affect only the specified modules.
Some Examples:
yiic migrate new --module=core
This will show you all new migrations for module core and
yiic migrate up 5 --module=core,user
will migrate up the next 5 new migrations in modules core and user. If there are new migrations in other modules they will be ignored.
yiic migrate history --module=core,user
will show you which migrations have been applied for modules core and user in the past. If you do not specify a module the command behaves like the native one and does the migration for all modules.
###add a module
Simply enable it in your config and run yiic migrate up --module=yourModule.
###remove a module
Run yiic migrate to m000000_000000 --module=yourModule. For this to work all your migrations must have the down()-method implemented correctly.
yiiext/migrate-command 适用场景与选型建议
yiiext/migrate-command 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 175.32k 次下载、GitHub Stars 达 34, 最近一次更新时间为 2013 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「yii」 「database-migration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yiiext/migrate-command 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yiiext/migrate-command 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yiiext/migrate-command 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Simple package to add database migrations to project
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 175.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 34
- 点击次数: 21
- 依赖项目数: 8
- 推荐数: 1
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2013-05-09