Mercurial > hg > soundsoftware-site
comparison db/migrate/.svn/text-base/078_add_custom_fields_position.rb.svn-base @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 class AddCustomFieldsPosition < ActiveRecord::Migration | |
2 def self.up | |
3 add_column(:custom_fields, :position, :integer, :default => 1) | |
4 CustomField.find(:all).group_by(&:type).each do |t, fields| | |
5 fields.each_with_index do |field, i| | |
6 # do not call model callbacks | |
7 CustomField.update_all "position = #{i+1}", {:id => field.id} | |
8 end | |
9 end | |
10 end | |
11 | |
12 def self.down | |
13 remove_column :custom_fields, :position | |
14 end | |
15 end |