mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-04-30 07:20:49 +08:00
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
18 lines
602 B
Ruby
18 lines
602 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddReplyQuotedToPosts < ActiveRecord::Migration[4.2]
|
|
def up
|
|
add_column :posts, :reply_quoted, :boolean, null: false, default: false
|
|
execute "UPDATE posts p
|
|
SET reply_quoted = true
|
|
WHERE EXISTS(
|
|
SELECT 1 FROM quoted_posts q
|
|
JOIN posts p1 ON p1.post_number = p.reply_to_post_number AND p1.topic_id = p.topic_id
|
|
WHERE q.post_id = p.id AND q.quoted_post_id = p1.id
|
|
) AND p.reply_to_post_number IS NOT NULL"
|
|
end
|
|
|
|
def down
|
|
remove_column :posts, :reply_quoted
|
|
end
|
|
end
|