Class: CreateAudits

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

Instance Method Summary collapse

Instance Method Details

#changeObject



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

def change
  create_table :audits do |t|
    t.belongs_to :auditable, :polymorphic => true
    t.belongs_to :user, :polymorphic => true
    t.text :modifications
    t.string :action
    t.string :tag
    t.integer :version
    t.timestamps
  end

  add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
  add_index :audits, [:auditable_id, :auditable_type, :version], :name => 'auditable_version_idx'
  add_index :audits, [:user_id, :user_type], :name => 'user_index'
  add_index :audits, :created_at
  add_index :audits, :action
  add_index :audits, :tag
end