diaspora/db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb
2017-09-17 19:29:15 +02:00

11 lines
405 B
Ruby

# frozen_string_literal: true
class CleanupRootGuidsFromReshares < ActiveRecord::Migration[5.1]
def up
# rubocop:disable Rails/SkipsModelValidations
Reshare.joins("LEFT OUTER JOIN posts as root ON root.guid = posts.root_guid")
.where("root.id is NULL AND posts.root_guid is NOT NULL")
.update_all(root_guid: nil)
# rubocop:enable Rails/SkipsModelValidations
end
end