mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 07:46:17 +01:00
Custom fields can now be reordered.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@901 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
15
db/migrate/078_add_custom_fields_position.rb
Normal file
15
db/migrate/078_add_custom_fields_position.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class AddCustomFieldsPosition < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column(:custom_fields, :position, :integer, :default => 1)
|
||||
CustomField.find(:all).group_by(&:type).each_value do |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
|
||||
Reference in New Issue
Block a user