2013-05-31 169 views
0

我正在运行Kohana 3.3并希望将数据库迁移添加到我的项目中。如何使用Minion任务迁移进行数据库迁移

我添加了以下模具https://github.com/kohana-minion/tasks-migrations,但不知道如何让它工作。

我可以看到运行./minion migrations:new --help的帮助文件,但我不明白需要什么group值。从文档它说:

--group=group_name 

This is a required config option, use it specify in which group the 
migration should be stored. Migrations are stored in a `migrations` 
directory followed by the group name specified. By default, the `migrations` 
directory is created in `APPPATH` but that can be changed with `--location` 

--location=modules/auth 

Specified the path of the migration (without the `migrations` directory). 
This value is defaulted to `APPPATH` 

# The migration will be created in `modules/myapp/migrations/myapp/` 
--group=myapp --location=modules/myapp 

--description="Description of migration here" 

This is an arbitrary description of the migration, used to build the 
filename. It is required but can be changed manually later on without 
affecting the integrity of the migration. 

我一直在寻找的例子,但还没有找到一个。我有一个现有的数据库,所以我想从该基础中获取该模式,然后再运行进一步的迁移。这是如何tasks-migrations模块的作品?

回答

1

组方法用于告诉你它是什么样的迁移。如果它是你的核心应用程序的迁移,那么core将是合适的。

但是,也许你为自己的应用程序建立了一个模块,它拥有自己的表格,从而自己进行迁移。因此最好使用组module_name

这样你可以在更适合的部分分割你的迁移,并能轻松地检查只是你的模块的迁移,而无需通过其他迁移进行搜索。

让新移民

./minion migrations:new --group=core 

运行迁移

./minion migrations:run 

PS:不要忘记将迁移表添加到数据库

+0

感谢,顺便说一句,它在运行时创建的迁移表第一次迁移。 – xylar

+0

顺便说一句,当它创建表时,当你使用innodb时,你也可以将它改为innodb。如果使用快速复制方法,混合表类型会导致数据库备份问题。 – RJD22

0

该组是移植版本号,例如

./minion migrations:new --group=0-1

创建在应用/迁移/ 0.1与上下方法的文件夹和文件的迁移。