mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
30990006a9
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
26 lines
665 B
Ruby
26 lines
665 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddIsQuoteToTopicLinks < ActiveRecord::Migration[4.2]
|
|
def up
|
|
add_column :topic_links, :quote, :boolean, default: false, null: false
|
|
|
|
# a primitive backfill, eventual rebake will catch missing
|
|
execute "
|
|
UPDATE topic_links
|
|
SET quote = true
|
|
WHERE id IN (
|
|
SELECT l.id
|
|
FROM topic_links l
|
|
JOIN posts p ON p.id = l.post_id
|
|
JOIN posts lp ON l.link_post_id = lp.id
|
|
WHERE p.raw LIKE '%\[quote=%post:' ||
|
|
lp.post_number::varchar || ',%topic:' ||
|
|
lp.topic_id::varchar || '%\]%\[/quote]%'
|
|
)"
|
|
end
|
|
|
|
def down
|
|
remove_column :topic_links, :quote
|
|
end
|
|
end
|