2014-10-06 20:16:12 +01:00
|
|
|
class CreateStatistics < ActiveRecord::Migration
|
|
|
|
def up
|
|
|
|
create_table :statistics do |t|
|
|
|
|
t.integer :user_id, null: false
|
|
|
|
t.string :email, null: false
|
|
|
|
t.integer :project_id, null: false
|
|
|
|
t.string :project_name_with_owner, null: false
|
2014-10-08 22:01:03 +01:00
|
|
|
t.string :key, null: false
|
2014-10-06 20:16:12 +01:00
|
|
|
t.integer :counter, null: false, default: 0
|
|
|
|
t.datetime :activity_at, null: false
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-10-07 16:53:26 +01:00
|
|
|
add_index :statistics, :user_id
|
|
|
|
add_index :statistics, :project_id
|
2014-10-08 22:01:03 +01:00
|
|
|
add_index :statistics, :key
|
|
|
|
add_index :statistics, [:user_id, :key, :activity_at]
|
|
|
|
add_index :statistics, [:project_id, :key, :activity_at]
|
|
|
|
add_index :statistics, [:key, :activity_at]
|
2014-10-07 16:53:26 +01:00
|
|
|
add_index :statistics, :activity_at
|
2014-10-06 20:16:12 +01:00
|
|
|
|
2014-10-08 22:01:03 +01:00
|
|
|
add_index :statistics, [:user_id, :project_id, :key, :activity_at], unique: true,
|
2014-10-06 20:16:12 +01:00
|
|
|
name: 'index_statistics_on_all_keys'
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
drop_table :statistics
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|