Plugin migrations for Redmine: place plugin in db/migrate instead of plugin folder

a 夏天 提交于 2019-12-08 12:17:24

问题


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.

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


回答1:


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.

The right syntax is for Rails 3.x (Redmine >= 2.x):

 rails generate redmine_plugin_model <plugin_name> <model_name> ...

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.

You should check the tutorials on the Redmine wiki about plugins.



来源:https://stackoverflow.com/questions/11607405/plugin-migrations-for-redmine-place-plugin-in-db-migrate-instead-of-plugin-fold

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!