summaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-01-07 10:03:11 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-01-07 10:03:11 +0000
commit0bc3ef5014dd8611fb1771061b57529bf4920e8b (patch)
tree22195b5e912bb9e6d518e1117eac6b6a614a9ca2 /db/migrate
parenta5f028a2424e2e234081b6a84c496fb6c563ee9c (diff)
downloadredmine-0bc3ef5014dd8611fb1771061b57529bf4920e8b.tar.gz
redmine-0bc3ef5014dd8611fb1771061b57529bf4920e8b.zip
Rails4: replace deprecated Relation#update_all at db migrations
git-svn-id: http://svn.redmine.org/redmine/trunk@12488 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20090401221305_update_enumerations_to_sti.rb6
-rw-r--r--db/migrate/20090614091200_fix_messages_sticky_null.rb2
-rw-r--r--db/migrate/20090704172350_populate_users_type.rb2
-rw-r--r--db/migrate/20091010093521_fix_users_custom_values.rb6
-rw-r--r--db/migrate/20100129193402_change_users_mail_notification_to_string.rb12
-rw-r--r--db/migrate/20110228000100_copy_repositories_log_encoding.rb3
-rw-r--r--db/migrate/20120223110929_change_attachments_container_defaults.rb4
7 files changed, 21 insertions, 14 deletions
diff --git a/db/migrate/20090401221305_update_enumerations_to_sti.rb b/db/migrate/20090401221305_update_enumerations_to_sti.rb
index 50bd52010..031dd4656 100644
--- a/db/migrate/20090401221305_update_enumerations_to_sti.rb
+++ b/db/migrate/20090401221305_update_enumerations_to_sti.rb
@@ -1,8 +1,8 @@
class UpdateEnumerationsToSti < ActiveRecord::Migration
def self.up
- Enumeration.update_all("type = 'IssuePriority'", "opt = 'IPRI'")
- Enumeration.update_all("type = 'DocumentCategory'", "opt = 'DCAT'")
- Enumeration.update_all("type = 'TimeEntryActivity'", "opt = 'ACTI'")
+ Enumeration.where("opt = 'IPRI'").update_all("type = 'IssuePriority'")
+ Enumeration.where("opt = 'DCAT'").update_all("type = 'DocumentCategory'")
+ Enumeration.where("opt = 'ACTI'").update_all("type = 'TimeEntryActivity'")
end
def self.down
diff --git a/db/migrate/20090614091200_fix_messages_sticky_null.rb b/db/migrate/20090614091200_fix_messages_sticky_null.rb
index cbe741732..fcb8b4504 100644
--- a/db/migrate/20090614091200_fix_messages_sticky_null.rb
+++ b/db/migrate/20090614091200_fix_messages_sticky_null.rb
@@ -1,6 +1,6 @@
class FixMessagesStickyNull < ActiveRecord::Migration
def self.up
- Message.update_all('sticky = 0', 'sticky IS NULL')
+ Message.where('sticky IS NULL').update_all('sticky = 0')
end
def self.down
diff --git a/db/migrate/20090704172350_populate_users_type.rb b/db/migrate/20090704172350_populate_users_type.rb
index 1c31feced..e7c72d532 100644
--- a/db/migrate/20090704172350_populate_users_type.rb
+++ b/db/migrate/20090704172350_populate_users_type.rb
@@ -1,6 +1,6 @@
class PopulateUsersType < ActiveRecord::Migration
def self.up
- Principal.update_all("type = 'User'", "type IS NULL")
+ Principal.where("type IS NULL").update_all("type = 'User'")
end
def self.down
diff --git a/db/migrate/20091010093521_fix_users_custom_values.rb b/db/migrate/20091010093521_fix_users_custom_values.rb
index 923c78fc0..93c5cfba2 100644
--- a/db/migrate/20091010093521_fix_users_custom_values.rb
+++ b/db/migrate/20091010093521_fix_users_custom_values.rb
@@ -1,9 +1,11 @@
class FixUsersCustomValues < ActiveRecord::Migration
def self.up
- CustomValue.update_all("customized_type = 'Principal'", "customized_type = 'User'")
+ CustomValue.where("customized_type = 'User'").
+ update_all("customized_type = 'Principal'")
end
def self.down
- CustomValue.update_all("customized_type = 'User'", "customized_type = 'Principal'")
+ CustomValue.where("customized_type = 'Principal'").
+ update_all("customized_type = 'User'")
end
end
diff --git a/db/migrate/20100129193402_change_users_mail_notification_to_string.rb b/db/migrate/20100129193402_change_users_mail_notification_to_string.rb
index 401f63407..518a450f4 100644
--- a/db/migrate/20100129193402_change_users_mail_notification_to_string.rb
+++ b/db/migrate/20100129193402_change_users_mail_notification_to_string.rb
@@ -2,16 +2,20 @@ class ChangeUsersMailNotificationToString < ActiveRecord::Migration
def self.up
rename_column :users, :mail_notification, :mail_notification_bool
add_column :users, :mail_notification, :string, :default => '', :null => false
- User.update_all("mail_notification = 'all'", "mail_notification_bool = #{connection.quoted_true}")
- User.update_all("mail_notification = 'selected'", "EXISTS (SELECT 1 FROM #{Member.table_name} WHERE #{Member.table_name}.mail_notification = #{connection.quoted_true} AND #{Member.table_name}.user_id = #{User.table_name}.id)")
- User.update_all("mail_notification = 'only_my_events'", "mail_notification NOT IN ('all', 'selected')")
+ User.where("mail_notification_bool = #{connection.quoted_true}").
+ update_all("mail_notification = 'all'")
+ User.where("EXISTS (SELECT 1 FROM #{Member.table_name} WHERE #{Member.table_name}.mail_notification = #{connection.quoted_true} AND #{Member.table_name}.user_id = #{User.table_name}.id)").
+ update_all("mail_notification = 'selected'")
+ User.where("mail_notification NOT IN ('all', 'selected')").
+ update_all("mail_notification = 'only_my_events'")
remove_column :users, :mail_notification_bool
end
def self.down
rename_column :users, :mail_notification, :mail_notification_char
add_column :users, :mail_notification, :boolean, :default => true, :null => false
- User.update_all("mail_notification = #{connection.quoted_false}", "mail_notification_char <> 'all'")
+ User.where("mail_notification_char <> 'all'").
+ update_all("mail_notification = #{connection.quoted_false}")
remove_column :users, :mail_notification_char
end
end
diff --git a/db/migrate/20110228000100_copy_repositories_log_encoding.rb b/db/migrate/20110228000100_copy_repositories_log_encoding.rb
index 314932883..48d387138 100644
--- a/db/migrate/20110228000100_copy_repositories_log_encoding.rb
+++ b/db/migrate/20110228000100_copy_repositories_log_encoding.rb
@@ -3,7 +3,8 @@ class CopyRepositoriesLogEncoding < ActiveRecord::Migration
encoding = Setting.commit_logs_encoding.to_s.strip
encoding = encoding.blank? ? 'UTF-8' : encoding
# encoding is NULL by default
- Repository.update_all(["log_encoding = ?", encoding], "type IN ('Bazaar', 'Cvs', 'Darcs')")
+ Repository.where("type IN ('Bazaar', 'Cvs', 'Darcs')").
+ update_all(["log_encoding = ?", encoding])
end
def self.down
diff --git a/db/migrate/20120223110929_change_attachments_container_defaults.rb b/db/migrate/20120223110929_change_attachments_container_defaults.rb
index f959f4c33..be720aafa 100644
--- a/db/migrate/20120223110929_change_attachments_container_defaults.rb
+++ b/db/migrate/20120223110929_change_attachments_container_defaults.rb
@@ -8,8 +8,8 @@ class ChangeAttachmentsContainerDefaults < ActiveRecord::Migration
change_column :attachments, :container_id, :integer, :default => nil, :null => true
change_column :attachments, :container_type, :string, :limit => 30, :default => nil, :null => true
- Attachment.update_all "container_id = NULL", "container_id = 0"
- Attachment.update_all "container_type = NULL", "container_type = ''"
+ Attachment.where("container_id = 0").update_all("container_id = NULL")
+ Attachment.where("container_type = ''").update_all("container_type = NULL")
add_index :attachments, [:container_id, :container_type]
end