master
 1# Migration responsible for creating a table with activities
 2class CreateActivities < ActiveRecord::Migration
 3  # Create table
 4  def self.up
 5    create_table :activities do |t|
 6      t.belongs_to :trackable, :polymorphic => true
 7      t.belongs_to :owner, :polymorphic => true
 8      t.string  :key
 9      t.text    :parameters
10      t.belongs_to :recipient, :polymorphic => true
11
12      t.timestamps
13    end
14
15    add_index :activities, [:trackable_id, :trackable_type]
16    add_index :activities, [:owner_id, :owner_type]
17    add_index :activities, [:recipient_id, :recipient_type]
18  end
19  # Drop table
20  def self.down
21    drop_table :activities
22  end
23end