Automating custom field creation in Redmine
plugins, redmine, ruby-on-rails
Solution
You should use migrate scripts. Put your scripts into `#{PLUGIN_ROOT}/db/migrate` and call `.create` there. The Redmine sources contain many similar scripts.
For example, the script can have a name: `001_populate_custom_fields.rb`.
Content:
class PopulateCustomFields < ActiveRecord::Migration
def self.up
CustomField.create ...
end
def self.down
end
end
Problem
I want to write a plugin for redmine that will depend on quite a few custom fields, so I would like to create the custom fields automatically. Ideally within the plugin code, or if not by a script I can run when I install the plugin - I really don't want to have to create 10+ fields through the web interface when I set this up, especially when one is a list with quite a few values. Can anyone tell me if there are standard ways of doing this? Also is there a good way to export the custom fields from an existing installation?