, script #{PLUGIN_ROOT}/db/migrate , / .
:
rake redmine:plugins:migrate
:
rake redmine:plugins:migrate NAME=<your plugin name> VERSION=0
.
, script 001_populate_custom_fields.rb :
class PopulateCustomFields < ActiveRecord::Migration
def self.up
if CustomField.find_by_name('A New Custom Field').nil?
CustomField.create(name: 'A New Custom Field', field_format: 'text')
end
end
def self.down
CustomField.find_by_name('A New Custom Field').delete unless CustomField.find_by_name('A New Custom Field').nil?
end
end
This will create / delete the custom field “New custom field” of type “text” after checking its existence from the table tables of the redmine database.
source
share