问题描述
我是红宝石的新手,正在创建redmine插件.我没有使用任何列就创建了模型Allissue
.现在,我想在迁移./script/generate migration AddRoleToAllissue project_name:string
的帮助下添加列project_name
.
I'm a newbie in ruby on rails and creating a redmine plugin. I created a model Allissue
without using any column. Now I wanted to add a column project_name
with the help of migration ./script/generate migration AddRoleToAllissue project_name:string
.
但是它将迁移放置在名为20120722192815_add_role_to_allissue.rb
的文件夹db/migrate
中,而不是插件迁移文件夹中.我关注了堆栈溢出问题,并将迁移的文件移至插件文件夹mv ./db/migrate/20120722192815_add_role_to_allissue.rb ./vendor/plugins/redmine_allissues/db/migrate/002_add_role_to_allissue.rb
.
But it places migration in folder db/migrate
named 20120722192815_add_role_to_allissue.rb
instead of plugin migrate folder. I followed stack-overflow question and move migrated file to plugin folder mv ./db/migrate/20120722192815_add_role_to_allissue.rb ./vendor/plugins/redmine_allissues/db/migrate/002_add_role_to_allissue.rb
.
我只是想知道插件迁移的替代方法,其中不需要将迁移的文件移动到插件文件夹.我不确定,但可能会有用于插件迁移的命令.谢谢
I just wanted to know alternative for plugin migration in which no need of moving migrated file to plugin folder. I'm not sure but there may be a command for plugin migration. Thanks
推荐答案
实际上,您是在生成Rails迁移,而不是Redmine插件迁移.这就是为什么您的迁移文件位于db/migrate
文件夹中的原因.
In fact, you are generating a Rails migration and not a Redmine plugin migration. This is why your migration file is in db/migrate
folder.
正确的语法适用于Rails 3.x(Redmine> = 2.x):
The right syntax is for Rails 3.x (Redmine >= 2.x):
rails generate redmine_plugin_model <plugin_name> <model_name> ...
对于Rails 2.x(Redmine< 2.x):
for Rails 2.x (Redmine <2.x):
script/generate redmine_plugin_model <plugin_name> <model_name> ...
它将在正确的位置生成迁移.
It will generate the migration in the right place.
您应该查看Redmine Wiki上有关插件的教程.
You should check the tutorials on the Redmine wiki about plugins.
这篇关于Redmine的插件迁移:将插件放在db/migrate中而不是插件文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!