mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Change TopicViewItem to allow null IP address
This commit is contained in:
@@ -58,13 +58,12 @@ end
|
|||||||
# topic_id :integer not null
|
# topic_id :integer not null
|
||||||
# viewed_at :date not null
|
# viewed_at :date not null
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# ip_address :inet not null
|
# ip_address :inet
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_topic_views_on_topic_id_and_viewed_at (topic_id,viewed_at)
|
# index_topic_views_on_topic_id_and_viewed_at (topic_id,viewed_at)
|
||||||
# index_topic_views_on_user_id_and_viewed_at (user_id,viewed_at)
|
# index_topic_views_on_user_id_and_viewed_at (user_id,viewed_at)
|
||||||
# index_topic_views_on_viewed_at_and_topic_id (viewed_at,topic_id)
|
# index_topic_views_on_viewed_at_and_topic_id (viewed_at,topic_id)
|
||||||
# ip_address_topic_id_topic_views (ip_address,topic_id) UNIQUE
|
# uniq_ip_or_user_id_topic_views (user_id,ip_address,topic_id) UNIQUE
|
||||||
# user_id_topic_id_topic_views (user_id,topic_id) UNIQUE
|
|
||||||
#
|
#
|
||||||
|
|||||||
25
db/migrate/20180521175611_change_indexes_topic_view_item.rb
Normal file
25
db/migrate/20180521175611_change_indexes_topic_view_item.rb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
class ChangeIndexesTopicViewItem < ActiveRecord::Migration[5.1]
|
||||||
|
def up
|
||||||
|
begin
|
||||||
|
Migration::SafeMigrate.disable!
|
||||||
|
change_column :topic_views, :ip_address, :inet, null: true
|
||||||
|
ensure
|
||||||
|
Migration::SafeMigrate.enable!
|
||||||
|
end
|
||||||
|
|
||||||
|
remove_index :topic_views,
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user