discourse/db/migrate/20230105153520_trigger_post_rebake_local_onebox_xss.rb
Selase Krakani bd2ca8d617
DEV: Promote historic post_deploy migrations (#25329)
This commit promotes all post_deploy migrations which existed in Discourse v3.1.0 (timestamp <= 20230405121454)
2024-01-19 13:59:20 +00:00

23 lines
468 B
Ruby

# frozen_string_literal: true
class TriggerPostRebakeLocalOneboxXss < ActiveRecord::Migration[7.0]
def up
val =
DB.query_single(
"SELECT value FROM site_settings WHERE name = 'content_security_policy'",
).first
return if val == nil || val == "t"
DB.exec(<<~SQL)
UPDATE posts
SET baked_version = NULL
WHERE cooked LIKE '%<a href=%'
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end