diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-02 14:33:20 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-02 14:33:20 +0100 |
commit | 3114e55c7a1e1640ed408986ccf3a63267a2653e (patch) | |
tree | 52fc3d6663f337081e2a60dfdc3570fe267cfd11 /db/migrate | |
parent | e3222feddb8335af5d1c9ac8b46730a2ca6d6502 (diff) |
Fix #323 - self-replies to appear in public timelines again
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb b/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb new file mode 100644 index 000000000..f93bc6565 --- /dev/null +++ b/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb @@ -0,0 +1,18 @@ +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 + Status.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status| + next if status.thread.nil? + + status.in_reply_to_account_id = status.thread.account_id + status.save! + end + end + end + + def down + remove_column :statuses, :in_reply_to_account_id + end +end |