mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-02-16 16:45:02 +00:00
FIX: applies a unique index for accepted_answer_post_id custom field (#83)
This commit is contained in:
parent
4c0545a827
commit
c0f8e2eee0
@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnsuresUniqueAcceptedAnswerPostId < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
execute <<~SQL
|
||||
DELETE FROM topic_custom_fields AS tcf1
|
||||
USING topic_custom_fields AS tcf2
|
||||
WHERE tcf1.id > tcf2.id AND
|
||||
tcf1.topic_id = tcf2.topic_id AND
|
||||
tcf1.name = tcf2.name AND
|
||||
tcf1.name = 'accepted_answer_post_id'
|
||||
SQL
|
||||
|
||||
add_index :topic_custom_fields,
|
||||
:topic_id,
|
||||
name: :idx_topic_custom_fields_accepted_answer,
|
||||
unique: true,
|
||||
where: "name = 'accepted_answer_post_id'"
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user