问题
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