discourse/db/migrate/20240527015009_add_topic_view_stats.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
478 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class AddTopicViewStats < ActiveRecord::Migration[7.0]
def change
create_table :topic_view_stats do |t|
t.integer :topic_id, null: false
t.date :viewed_at, null: false
t.integer :anonymous_views, default: 0, null: false
t.integer :logged_in_views, default: 0, null: false
end
add_index :topic_view_stats, %i[topic_id viewed_at], unique: true
add_index :topic_view_stats, %i[viewed_at topic_id]
end
end