Skip to content

Commit

Permalink
ECF-410 Fix paper trail audit schema datatype (#176)
Browse files Browse the repository at this point in the history
* fix audit schema

* add default uuid to appease rubocop
  • Loading branch information
amazimbe authored Mar 24, 2021
1 parent 9082158 commit 63e38d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions db/migrate/20210323180540_change_item_id_type_to_uuid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class ChangeItemIdTypeToUuid < ActiveRecord::Migration[6.1]
def change
remove_column :versions, :item_id, :bigint
remove_index :versions, column: %i[item_type item_id], if_exists: true
add_column :versions, :item_id, :uuid, default: "gen_random_uuid()", null: false
add_index :versions, %i[item_type item_id]
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_03_19_153015) do
ActiveRecord::Schema.define(version: 2021_03_23_180540) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
Expand Down Expand Up @@ -285,12 +285,12 @@

create_table "versions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "item_type", null: false
t.bigint "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.uuid "item_id", default: -> { "gen_random_uuid()" }, null: false
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end

Expand Down

0 comments on commit 63e38d6

Please sign in to comment.