20220309213005_fix_reblog_deleted_at.rb 392 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. class FixReblogDeletedAt < ActiveRecord::Migration[6.1]
  3. disable_ddl_transaction!
  4. def up
  5. safety_assured do
  6. execute <<~SQL.squish
  7. UPDATE statuses s
  8. SET deleted_at = r.deleted_at
  9. FROM statuses r
  10. WHERE
  11. s.reblog_of_id = r.id
  12. AND r.deleted_at IS NOT NULL
  13. SQL
  14. end
  15. end
  16. def down; end
  17. end