Adding versioning

This commit is contained in:
2013-10-09 03:34:27 -07:00
parent 5a94d69b3d
commit ebc696814e
11 changed files with 101 additions and 46 deletions

View File

@@ -2,7 +2,7 @@ class CreateSpaces < ActiveRecord::Migration
def change
create_table :spaces do |t|
t.string :name
t.string :type
t.string :category
t.string :address
t.string :hours
t.string :phone

View File

@@ -0,0 +1,18 @@
class CreateVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
add_index :versions, [:item_type, :item_id]
end
def self.down
remove_index :versions, [:item_type, :item_id]
drop_table :versions
end
end

View File

@@ -11,11 +11,11 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20131009050712) do
ActiveRecord::Schema.define(version: 20131009051102) do
create_table "spaces", force: true do |t|
t.string "name"
t.string "type"
t.string "category"
t.string "address"
t.string "hours"
t.string "phone"
@@ -26,4 +26,15 @@ ActiveRecord::Schema.define(version: 20131009050712) do
t.datetime "updated_at"
end
create_table "versions", force: true do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
end
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end