Add uniq_ip_or_user_id_topic_views index concurrently.
This commit is contained in:
parent
c0c263405a
commit
59e72b466a
|
@ -11,13 +11,11 @@ class ChangeIndexesTopicViewItem < ActiveRecord::Migration[5.1]
|
|||
column: [:ip_address, :topic_id],
|
||||
name: :ip_address_topic_id_topic_views,
|
||||
unique: true
|
||||
|
||||
remove_index :topic_views,
|
||||
column: [:user_id, :topic_id],
|
||||
name: :user_id_topic_id_topic_views,
|
||||
unique: true
|
||||
add_index :topic_views, [:user_id, :ip_address, :topic_id],
|
||||
name: :uniq_ip_or_user_id_topic_views,
|
||||
unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class AddUniqIpOrUserIdTopicViews < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
unless index_exists?(:topic_views, [:user_id, :ip_address, :topic_id],
|
||||
name: :uniq_ip_or_user_id_topic_views
|
||||
)
|
||||
|
||||
add_index :topic_views, [:user_id, :ip_address, :topic_id],
|
||||
name: :uniq_ip_or_user_id_topic_views,
|
||||
unique: true,
|
||||
algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue