Replace usages of the deprecated delete_all with conditions
This commit is contained in:
parent
b614237504
commit
ef70549832
7 changed files with 13 additions and 12 deletions
|
|
@ -52,7 +52,7 @@ class ExtendPods < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
|
||||
# cleanup unused pods
|
||||
Pod.joins("LEFT OUTER JOIN people ON pods.id = people.pod_id").delete_all("people.id is NULL")
|
||||
Pod.joins("LEFT OUTER JOIN people ON pods.id = people.pod_id").where("people.id is NULL").delete_all
|
||||
|
||||
remove_column :people, :url
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class LinkShareVisibilitiesWithUser < ActiveRecord::Migration[4.2]
|
|||
remove_column :share_visibilities, :contact_id
|
||||
|
||||
ShareVisibility.joins("LEFT OUTER JOIN users ON users.id = share_visibilities.user_id")
|
||||
.delete_all("users.id is NULL")
|
||||
.where("users.id is NULL").delete_all
|
||||
|
||||
change_column :share_visibilities, :user_id, :integer, null: false
|
||||
|
||||
|
|
@ -73,8 +73,8 @@ class LinkShareVisibilitiesWithUser < ActiveRecord::Migration[4.2]
|
|||
|
||||
def cleanup_deleted_share_visibilities
|
||||
ShareVisibility.joins("LEFT OUTER JOIN posts ON posts.id = share_visibilities.shareable_id")
|
||||
.where(shareable_type: "Post").delete_all("posts.id is NULL")
|
||||
.where(shareable_type: "Post").where("posts.id is NULL").delete_all
|
||||
ShareVisibility.joins("LEFT OUTER JOIN photos ON photos.id = share_visibilities.shareable_id")
|
||||
.where(shareable_type: "Photo").delete_all("photos.id is NULL")
|
||||
.where(shareable_type: "Photo").where("photos.id is NULL").delete_all
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ class CleanupAspectVisibility < ActiveRecord::Migration[4.2]
|
|||
|
||||
def up
|
||||
AspectVisibility.joins("LEFT OUTER JOIN posts ON posts.id = aspect_visibilities.shareable_id")
|
||||
.where(shareable_type: "Post").delete_all("posts.id is NULL")
|
||||
.where(shareable_type: "Post").where("posts.id is NULL").delete_all
|
||||
AspectVisibility.joins("LEFT OUTER JOIN photos ON photos.id = aspect_visibilities.shareable_id")
|
||||
.where(shareable_type: "Photo").delete_all("photos.id is NULL")
|
||||
.where(shareable_type: "Photo").where("photos.id is NULL").delete_all
|
||||
AspectVisibility.joins("INNER JOIN posts ON posts.id = aspect_visibilities.shareable_id")
|
||||
.where(shareable_type: "Post").delete_all(posts: {public: true})
|
||||
.where(shareable_type: "Post").where(posts: {public: true}).delete_all
|
||||
AspectVisibility.joins("INNER JOIN photos ON photos.id = aspect_visibilities.shareable_id")
|
||||
.where(shareable_type: "Photo").delete_all(photos: {public: true})
|
||||
.where(shareable_type: "Photo").where(photos: {public: true}).delete_all
|
||||
|
||||
remove_columns :aspect_visibilities, :created_at, :updated_at
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ class CleanupParticipations < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
|
||||
Participation.joins("LEFT OUTER JOIN posts ON posts.id = participations.target_id")
|
||||
.where(target_type: "Post").delete_all("posts.id is NULL")
|
||||
.where(target_type: "Post").where("posts.id is NULL").delete_all
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration[4.2]
|
|||
InvitationCode.where("count < 0").update_all(count: new_counter)
|
||||
|
||||
# remove old invitation-users
|
||||
User.delete_all(username: nil)
|
||||
User.where(username: nil).delete_all
|
||||
change_column :users, :username, :string, null: false
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration[
|
|||
.joins("INNER JOIN people ON people.id = notifications.target_id")
|
||||
.joins("LEFT OUTER JOIN contacts ON contacts.person_id = people.id " \
|
||||
"AND contacts.user_id = notifications.recipient_id")
|
||||
.delete_all("contacts.id IS NULL")
|
||||
.where("contacts.id IS NULL")
|
||||
.delete_all
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class RemoveEmptyPod < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
Pod.delete_all("host IS NULL")
|
||||
Pod.where("host IS NULL").delete_all
|
||||
|
||||
change_column :pods, :host, :string, null: false
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue