YII Framework学习教程-用YIIC快速创建YII应用之二-2011-11-11
2011-11-11 10:10
711 查看
3.yii migrate
查看帮助
在我们开发程序的过程中,数据库的结构也是不断调整的。我们的开发中要保证代码和数据库库的同步。因为我们的应用离不开数据库。例如: 在开发过程中,我们经常需要增加一个新的表,或者我们后期投入运营的产品,可能需要为某一列添加索引。我们必须保持数据结构和代码的一致性。如果代码和数据库不同步,可能整个系统将无法正常运行。出于这个原因。yii提供了一个数据库迁移工具,可以保持代码和数据库是同步。方便数据库的回滚和更新。
功能正如描述。主要提供了数据库迁移功能。
命令格式
action参数用来制定执行哪一个迁移任务。可以一使用
如果没有action参数,默认为up
parameter根据action的不同而有所变化。
上述例子中给出了说明。
官方也给出了详细的例子。
http://www.yiiframework.com/doc/guide/1.1/zh_cn/database.migration#creating-migrations
这里不再详细累述。用到的时候参考使用就可以了。
查看帮助
/* /www/yii_dev/yii/framework# php yiic migrate help Error: Unknown action: help USAGE yiic migrate [action] [parameter] DESCRIPTION This command provides support for database migrations. The optional 'action' parameter specifies which specific migration task to perform. It can take these values: up, down, to, create, history, new, mark. If the 'action' parameter is not given, it defaults to 'up'. Each action takes different parameters. Their usage can be found in the following examples.
EXAMPLES * yiic migrate Applies ALL new migrations. This is equivalent to 'yiic migrate to'. * yiic migrate create create_user_table Creates a new migration named 'create_user_table'. * yiic migrate up 3 Applies the next 3 new migrations. * yiic migrate down Reverts the last applied migration. * yiic migrate down 3 Reverts the last 3 applied migrations. * yiic migrate to 101129_185401 Migrates up or down to version 101129_185401. * yiic migrate mark 101129_185401 Modifies the migration history up or down to version 101129_185401. No actual migration will be performed. * yiic migrate history Shows all previously applied migration information. * yiic migrate history 10 Shows the last 10 applied migrations. * yiic migrate new Shows all new migrations. * yiic migrate new 10 Shows the next 10 migrations that have not been applied. */
在我们开发程序的过程中,数据库的结构也是不断调整的。我们的开发中要保证代码和数据库库的同步。因为我们的应用离不开数据库。例如: 在开发过程中,我们经常需要增加一个新的表,或者我们后期投入运营的产品,可能需要为某一列添加索引。我们必须保持数据结构和代码的一致性。如果代码和数据库不同步,可能整个系统将无法正常运行。出于这个原因。yii提供了一个数据库迁移工具,可以保持代码和数据库是同步。方便数据库的回滚和更新。
功能正如描述。主要提供了数据库迁移功能。
命令格式
yiic migrate [action] [parameter]
action参数用来制定执行哪一个迁移任务。可以一使用
up, down, to, create, history, new, mark.这些命令
如果没有action参数,默认为up
parameter根据action的不同而有所变化。
上述例子中给出了说明。
官方也给出了详细的例子。
http://www.yiiframework.com/doc/guide/1.1/zh_cn/database.migration#creating-migrations
这里不再详细累述。用到的时候参考使用就可以了。
相关文章推荐
- YII Framework学习教程-用YIIC快速创建YII应用之三-2011-11-11
- YII Framework学习教程-用YIIC快速创建YII应用之四-扩展yiic自定义命令-2011-11-11
- YII Framework学习教程-用YIIC快速创建YII应用之三
- YII Framework学习教程-用YIIC快速创建YII应用-2011-11-10
- YII Framework框架教程之使用YIIC快速创建YII应用详解
- YII Framework框架教程之使用YIIC快速创建YII应用详解
- YII Framework框架使用YIIC快速创建YII应用之migrate用法实例详解
- YII Framework框架使用YIIC快速创建YII应用之migrate用法实例详解
- YII Framework学习教程-YII目录结构-2011-11-11
- YII Framework学习教程-YII架构设计官方图解-2011-11-11
- YII之yiic创建YII应用出现的问题
- 快速使用 Thinkphp 之二: 创建自己的应用项目
- YII Framework学习教程-YII的Model-Controllers和Models-2011-11-22
- YII Framework学习教程-YII的Model-数据库操作1-CActiveRecord
- YII Framework学习教程-YII的V-view的layout
- YII Framework学习教程-YII的V-view的Exception-2011-11-17
- YII Framework学习教程-YII的cookie\session2011-11-21
- YII Framework学习教程-YII的分页CPagination-2011-11-23
- YII之yiic创建YII应用
- Yii Framework 开发教程(2) Yii Web应用基础