discourse-solved/db/migrate/20210429154322_remove_nil_custom_fields_from_solved.rb

25 lines
572 B
Ruby
Raw Permalink Normal View History

2021-05-05 12:19:00 +02:00
# frozen_string_literal: true
class RemoveNilCustomFieldsFromSolved < ActiveRecord::Migration[6.0]
def up
execute <<~SQL
DELETE FROM post_custom_fields
WHERE name = 'is_accepted_answer' AND value IS NULL
SQL
execute <<~SQL
DELETE FROM topic_custom_fields
WHERE name = 'accepted_answer_post_id' AND value IS NULL
SQL
execute <<~SQL
DELETE FROM topic_custom_fields
WHERE name = 'solved_auto_close_topic_timer_id' AND value IS NULL
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end