diff --git a/Gemfile b/Gemfile index 9876892..04c6da3 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,8 @@ gem 'jsonapi-resources' gem 'rack-cors', :require => 'rack/cors' +gem 'paper_trail', '~> 4.0.0' + group :production do gem 'pg' end diff --git a/Gemfile.lock b/Gemfile.lock index ba4548d..4a0a7b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,10 @@ GEM minitest (5.8.0) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) + paper_trail (4.0.0) + activerecord (>= 3.0, < 6.0) + activesupport (>= 3.0, < 6.0) + request_store (~> 1.1) pg (0.18.3) pry (0.10.1) coderay (~> 1.1.0) @@ -96,6 +100,7 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.4.2) + request_store (1.2.0) rspec-core (3.3.2) rspec-support (~> 3.3.0) rspec-expectations (3.3.1) @@ -114,7 +119,7 @@ GEM rspec-support (~> 3.3.0) rspec-support (3.3.0) slop (3.6.0) - spring (1.3.6) + spring (1.6.3) sprockets (3.3.4) rack (~> 1.0) sprockets-rails (2.3.3) @@ -133,6 +138,7 @@ PLATFORMS DEPENDENCIES factory_girl_rails (~> 4.0) jsonapi-resources + paper_trail (~> 4.0.0) pg pry rack-cors @@ -142,4 +148,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.10.6 + 1.11.2 diff --git a/db/migrate/20151014232426_create_versions.rb b/db/migrate/20151014232426_create_versions.rb new file mode 100644 index 0000000..3876dfc --- /dev/null +++ b/db/migrate/20151014232426_create_versions.rb @@ -0,0 +1,20 @@ +class CreateVersions < ActiveRecord::Migration + + # The largest text column available in all supported RDBMS is + # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size + # so that MySQL will use `longtext` instead of `text`. Otherwise, + # when serializing very large objects, `text` might not be big enough. + TEXT_BYTES = 1_073_741_823 + + def change + 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, :limit => TEXT_BYTES + t.datetime :created_at + end + add_index :versions, [:item_type, :item_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 3179772..ea89fab 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150921161235) do +ActiveRecord::Schema.define(version: 20151014232426) do + + create_table "internets", force: :cascade do |t| + t.string "address" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end create_table "locations", force: :cascade do |t| t.string "name" @@ -43,4 +49,15 @@ add_index "things", ["location_id"], name: "index_things_on_location_id" add_index "things", ["name"], name: "index_things_on_name", unique: true + create_table "versions", force: :cascade 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", limit: 1073741823 + t.datetime "created_at" + end + + add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" + end