discourse/db/migrate/20131223171005_create_top_topics.rb

24 lines
558 B
Ruby
Raw Normal View History

2013-12-23 18:50:36 -05:00
class CreateTopTopics < ActiveRecord::Migration
def change
create_table :top_topics do |t|
2013-12-23 18:50:36 -05:00
t.belongs_to :topic
TopTopic.periods.each do |period|
TopTopic.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
TopTopic.periods.each do |period|
TopTopic.sort_orders.each do |sort|
add_index :top_topics, "#{period}_#{sort}_count".to_sym, order: 'desc'
end
end
end
end