From 1250612ac928b0ed348c2b03fbb45a0a5dbfbcf6 Mon Sep 17 00:00:00 2001 From: ConnorSheremeta Date: Thu, 10 Mar 2016 11:54:43 -0700 Subject: [PATCH] setting up paper trail --- backend/Gemfile | 3 +++ .../migrate/20160310183317_create_versions.rb | 13 +++++++++++++ backend/db/schema.rb | 18 +++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 backend/db/migrate/20160310183317_create_versions.rb diff --git a/backend/Gemfile b/backend/Gemfile index f3e17d2..8140e99 100644 --- a/backend/Gemfile +++ b/backend/Gemfile @@ -16,6 +16,9 @@ gem 'bcrypt' gem 'jwt' +# for maintaining audits +gem 'paper_trail', '~> 4.0.2' + # for windows gem 'tzinfo-data', platforms: [:x64_mingw,:mingw, :mswin] diff --git a/backend/db/migrate/20160310183317_create_versions.rb b/backend/db/migrate/20160310183317_create_versions.rb new file mode 100644 index 0000000..23be970 --- /dev/null +++ b/backend/db/migrate/20160310183317_create_versions.rb @@ -0,0 +1,13 @@ +class CreateVersions < ActiveRecord::Migration + 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 + t.datetime :created_at + end + add_index :versions, [:item_type, :item_id] + end +end diff --git a/backend/db/schema.rb b/backend/db/schema.rb index 2c0ec2a..5441d3c 100644 --- a/backend/db/schema.rb +++ b/backend/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160224070033) do +ActiveRecord::Schema.define(version: 20160310183317) do create_table "admins", force: :cascade do |t| t.datetime "created_at", null: false @@ -22,6 +22,11 @@ add_index "admins", ["approved"], name: "index_admins_on_approved" + create_table "audit_trails", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "degrees", force: :cascade do |t| t.integer "year", null: false t.string "degree_type", null: false @@ -96,4 +101,15 @@ add_index "users", ["approved"], name: "index_users_on_approved" + 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" + t.datetime "created_at" + end + + add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" + end