remove unused post/topic custom fields
This commit is contained in:
parent
150f7f4a35
commit
56f8327234
|
@ -36,14 +36,51 @@ class MoveSolvedTopicCustomFieldToDiscourseSolvedSolutions < ActiveRecord::Migra
|
|||
AND ua.action_type = #{UserAction::SOLVED}
|
||||
SQL
|
||||
|
||||
# execute <<-SQL
|
||||
# DELETE FROM post_custom_fields
|
||||
# WHERE name = 'is_accepted_answer'
|
||||
# SQL
|
||||
execute <<-SQL
|
||||
DELETE FROM post_custom_fields
|
||||
WHERE name = 'is_accepted_answer'
|
||||
SQL
|
||||
|
||||
execute <<-SQL
|
||||
DELETE FROM topic_custom_fields
|
||||
WHERE name = 'solved_auto_close_topic_timer_id'
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
# raise ActiveRecord::IrreversibleMigration
|
||||
execute <<-SQL
|
||||
INSERT INTO topic_custom_fields (
|
||||
topic_id,
|
||||
name,
|
||||
value,
|
||||
created_at,
|
||||
updated_at
|
||||
) SELECT DISTINCT
|
||||
topic_id,
|
||||
'solved_auto_close_topic_timer_id',
|
||||
CAST(topic_timer_id AS TEXT),
|
||||
created_at,
|
||||
updated_at
|
||||
FROM discourse_solved_solutions tc
|
||||
WHERE tc.topic_timer_id IS NOT NULL
|
||||
SQL
|
||||
|
||||
execute <<-SQL
|
||||
INSERT INTO post_custom_fields (
|
||||
post_id,
|
||||
name,
|
||||
value,
|
||||
created_at,
|
||||
updated_at
|
||||
) SELECT DISTINCT
|
||||
answer_post_id,
|
||||
'is_accepted_answer',
|
||||
'true',
|
||||
created_at,
|
||||
updated_at
|
||||
FROM discourse_solved_solutions
|
||||
SQL
|
||||
|
||||
remove_index :discourse_solved_solutions, :topic_id
|
||||
remove_index :discourse_solved_solutions, :answer_post_id
|
||||
|
||||
|
|
Loading…
Reference in New Issue