diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-04 17:04:50 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-04 17:04:50 +0000 |
commit | c216ab325bc56123819fb5b700a759753959ead8 (patch) | |
tree | a90493432ae7a2ca681c193e65627d16341bf53e /db/migrate/072_add_enumerations_position.rb | |
parent | 479b9b54336c3fa5ce3f9fccb56307a52b48dd0c (diff) | |
download | redmine-c216ab325bc56123819fb5b700a759753959ead8.tar.gz redmine-c216ab325bc56123819fb5b700a759753959ead8.zip |
Added position on Enumeration model.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@800 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate/072_add_enumerations_position.rb')
-rw-r--r-- | db/migrate/072_add_enumerations_position.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/db/migrate/072_add_enumerations_position.rb b/db/migrate/072_add_enumerations_position.rb new file mode 100644 index 000000000..7def86772 --- /dev/null +++ b/db/migrate/072_add_enumerations_position.rb @@ -0,0 +1,12 @@ +class AddEnumerationsPosition < ActiveRecord::Migration + def self.up + add_column :enumerations, :position, :integer, :default => 1, :null => false + Enumeration.find(:all).group_by(&:opt).each_value do |enums| + enums.each_with_index {|enum, i| enum.update_attribute(:position, i+1)} + end + end + + def self.down + remove_column :enumerations, :position + end +end |