You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
533 B

  1. class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0]
  2. def up
  3. add_column :statuses, :in_reply_to_account_id, :integer, null: true, default: nil
  4. ActiveRecord::Base.transaction do
  5. Status.unscoped.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status|
  6. next if status.thread.nil?
  7. status.in_reply_to_account_id = status.thread.account_id
  8. status.save(validate: false)
  9. end
  10. end
  11. end
  12. def down
  13. remove_column :statuses, :in_reply_to_account_id
  14. end
  15. end