Class: CreateActivities

Inherits:
ActiveRecord::Migration
  • 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


20
21
22
# File 'lib/generators/public_activity/migration/templates/migration.rb', line 20

def self.down
  drop_table :activities
end

.upObject

Create table


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

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