Class: CreateChanges

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

Instance Method Summary collapse

Instance Method Details

#downObject



13
14
15
# File 'lib/generators/historyable/templates/migration.rb', line 13

def down
  drop_table :changes
end

#upObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/generators/historyable/templates/migration.rb', line 2

def up
  create_table :changes do |t|
    t.references :item, polymorphic: true
    t.string     :object_attribute
    t.text       :object_attribute_value
    t.datetime   :created_at
  end

  add_index :changes, [:item_type, :item_id]
end