diff .svn/pristine/f0/f08dcd38ee8d5ba63486881b16a9b731dc527af3.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/f0/f08dcd38ee8d5ba63486881b16a9b731dc527af3.svn-base	Tue Jan 14 14:37:42 2014 +0000
@@ -0,0 +1,15 @@
+class AddEnumerationsPosition < ActiveRecord::Migration
+  def self.up
+    add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position')
+    Enumeration.all.group_by(&:opt).each do |opt, enums|
+      enums.each_with_index do |enum, i|
+        # do not call model callbacks
+        Enumeration.update_all "position = #{i+1}", {:id => enum.id}
+      end
+    end
+  end
+
+  def self.down
+    remove_column :enumerations, :position
+  end
+end