Class: CreateWiserTrails

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/wiser_trails/migration/templates/migration.rb

Overview

Migration responsible for creating a table with trails

Class Method Summary collapse

Class Method Details

.downObject

Drop table



21
22
23
# File 'lib/generators/wiser_trails/migration/templates/migration.rb', line 21

def self.down
  drop_table :wiser_trails
end

.upObject

Create table



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

def self.up
  create_table :wiser_trails do |t|
    t.belongs_to :trackable, :polymorphic => true
    t.belongs_to :account, :polymorphic => true
    t.belongs_to :owner, :polymorphic => true
    t.string :key
    t.text :old_value
    t.text :new_value

    t.timestamps
  end

  add_index :wiser_trails, [:trackable_id, :trackable_type]
  add_index :wiser_trails, [:account_id, :account_type]
  add_index :wiser_trails, [:owner_id, :owner_type]
end