mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 03:13:39 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
29 lines
662 B
Ruby
29 lines
662 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CreateTopTopics < ActiveRecord::Migration[4.2]
|
|
PERIODS = [:yearly, :monthly, :weekly, :daily]
|
|
SORT_ORDERS = [:posts, :views, :likes]
|
|
|
|
def change
|
|
create_table :top_topics, force: true do |t|
|
|
t.belongs_to :topic
|
|
|
|
PERIODS.each do |period|
|
|
SORT_ORDERS.each do |sort|
|
|
t.integer "#{period}_#{sort}_count".to_sym, null: false, default: 0
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
add_index :top_topics, :topic_id, unique: true
|
|
|
|
PERIODS.each do |period|
|
|
SORT_ORDERS.each do |sort|
|
|
add_index :top_topics, "#{period}_#{sort}_count".to_sym, order: 'desc'
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|