2016-12-02 22:33:20 +09:00
|
|
|
class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0]
|
|
|
|
def up
|
|
|
|
add_column :statuses, :in_reply_to_account_id, :integer, null: true, default: nil
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
2019-09-28 08:05:26 +09:00
|
|
|
Status.unscoped.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status|
|
2016-12-02 22:33:20 +09:00
|
|
|
next if status.thread.nil?
|
|
|
|
|
|
|
|
status.in_reply_to_account_id = status.thread.account_id
|
2016-12-02 23:09:44 +09:00
|
|
|
status.save(validate: false)
|
2016-12-02 22:33:20 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_column :statuses, :in_reply_to_account_id
|
|
|
|
end
|
|
|
|
end
|