Mercurial > hg > soundsoftware-site
diff .svn/pristine/66/66ab27fbec26a34302ffce7f06e525b4e0ebdfde.svn-base @ 1464:261b3d9a4903 redmine-2.4
Update to Redmine 2.4 branch rev 12663
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2014 14:37:42 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.svn/pristine/66/66ab27fbec26a34302ffce7f06e525b4e0ebdfde.svn-base Tue Jan 14 14:37:42 2014 +0000 @@ -0,0 +1,15 @@ +class AddCustomFieldsPosition < ActiveRecord::Migration + def self.up + add_column(:custom_fields, :position, :integer, :default => 1) + CustomField.all.group_by(&:type).each do |t, fields| + fields.each_with_index do |field, i| + # do not call model callbacks + CustomField.update_all "position = #{i+1}", {:id => field.id} + end + end + end + + def self.down + remove_column :custom_fields, :position + end +end