diff .svn/pristine/66/66ab27fbec26a34302ffce7f06e525b4e0ebdfde.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.svn/pristine/66/66ab27fbec26a34302ffce7f06e525b4e0ebdfde.svn-base	Fri Jun 14 09:28:30 2013 +0100
@@ -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