Class: CreateActivities

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/public_activity/migration/templates/migration.rb

Overview

Migration responsible for creating a table with activities

Class Method Summary collapse

Class Method Details

.downObject

Drop table


22
23
24
# File 'lib/generators/public_activity/migration/templates/migration.rb', line 22

def self.down
  drop_table :activities
end

.upObject

Create table


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/public_activity/migration/templates/migration.rb', line 6

def self.up
  create_table :activities do |t|
    t.belongs_to :trackable, :polymorphic => true
    t.belongs_to :owner, :polymorphic => true
    t.string  :key
    t.text    :parameters
    t.belongs_to :recipient, :polymorphic => true

    t.timestamps
  end

  add_index :activities, [:trackable_id, :trackable_type]
  add_index :activities, [:owner_id, :owner_type]
  add_index :activities, [:recipient_id, :recipient_type]
end