Commit b5176268 authored by marutosijp's avatar marutosijp
Browse files

use symbol instead of string for 'position' in db migrate (#24013)

git-svn-id: https://svn.redmine.org/redmine/trunk@16009 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent aeabf778
...@@ -4,7 +4,7 @@ class AddEnumerationsPosition < ActiveRecord::Migration ...@@ -4,7 +4,7 @@ class AddEnumerationsPosition < ActiveRecord::Migration
Enumeration.all.group_by(&:opt).each do |opt, enums| Enumeration.all.group_by(&:opt).each do |opt, enums|
enums.each_with_index do |enum, i| enums.each_with_index do |enum, i|
# do not call model callbacks # do not call model callbacks
Enumeration.where({:id => enum.id}).update_all("position = #{i+1}") Enumeration.where({:id => enum.id}).update_all(:position => (i+1))
end end
end end
end end
......
...@@ -4,7 +4,7 @@ class AddCustomFieldsPosition < ActiveRecord::Migration ...@@ -4,7 +4,7 @@ class AddCustomFieldsPosition < ActiveRecord::Migration
CustomField.all.group_by(&:type).each do |t, fields| CustomField.all.group_by(&:type).each do |t, fields|
fields.each_with_index do |field, i| fields.each_with_index do |field, i|
# do not call model callbacks # do not call model callbacks
CustomField.where({:id => field.id}).update_all("position = #{i+1}") CustomField.where({:id => field.id}).update_all(:position => (i+1))
end end
end end
end end
......
...@@ -6,7 +6,7 @@ class RemoveIssueStatusesIsDefault < ActiveRecord::Migration ...@@ -6,7 +6,7 @@ class RemoveIssueStatusesIsDefault < ActiveRecord::Migration
def down def down
add_column :issue_statuses, :is_default, :boolean, :null => false, :default => false add_column :issue_statuses, :is_default, :boolean, :null => false, :default => false
# Restores the first status as default # Restores the first status as default
default_status_id = IssueStatus.order("position").pluck(:id).first default_status_id = IssueStatus.order(:position).pluck(:id).first
IssueStatus.where(:id => default_status_id).update_all(:is_default => true) IssueStatus.where(:id => default_status_id).update_all(:is_default => true)
end end
end end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment