Mercurial > hg > soundsoftware-site
comparison .svn/pristine/f0/f08dcd38ee8d5ba63486881b16a9b731dc527af3.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 |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 class AddEnumerationsPosition < ActiveRecord::Migration | |
2 def self.up | |
3 add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position') | |
4 Enumeration.all.group_by(&:opt).each do |opt, enums| | |
5 enums.each_with_index do |enum, i| | |
6 # do not call model callbacks | |
7 Enumeration.update_all "position = #{i+1}", {:id => enum.id} | |
8 end | |
9 end | |
10 end | |
11 | |
12 def self.down | |
13 remove_column :enumerations, :position | |
14 end | |
15 end |