summaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-12 17:23:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-12 17:23:14 +0000
commit5944696b6d4307de0166ba74c514aae25779abb9 (patch)
treec2543b32f0319c9e87efa7074d378e86bd60af78 /db/migrate
parenta727f0d25a1e9f23be869a1dc413485b43a16935 (diff)
downloadredmine-5944696b6d4307de0166ba74c514aae25779abb9.tar.gz
redmine-5944696b6d4307de0166ba74c514aae25779abb9.zip
Custom fields can now be reordered.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@901 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/078_add_custom_fields_position.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/078_add_custom_fields_position.rb b/db/migrate/078_add_custom_fields_position.rb
new file mode 100644
index 000000000..7ee8abb58
--- /dev/null
+++ b/db/migrate/078_add_custom_fields_position.rb
@@ -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