Class: CreateAudits

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

Class Method Summary collapse

Class Method Details

.downObject



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

def self.down
  drop_table :audits
end

.upObject



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

def self.up
  create_table :audits do |t|
    t.string  :action
    t.string  :auditable_type
    t.integer :auditable_id
    t.string  :association_type
    t.integer :association_id
    t.string  :field_name
    t.text    :old_value
    t.text    :new_value
    # t.integer :user_id
    t.boolean :undoable, :default => true
    t.timestamps
  end
  
  add_index :audits, [:auditable_type, :auditable_id]
  add_index :audits, [:association_type, :association_id]
end