|
1
|
|
|
# frozen_string_literal: true |
|
2
|
|
|
|
|
3
|
|
|
# Stores audit information using audited gem |
|
4
|
|
|
class InstallAudited < ActiveRecord::Migration[5.1] |
|
5
|
|
|
def change |
|
6
|
|
|
create_table :audits, force: true do |t| |
|
7
|
|
|
t.column :auditable_id, :integer |
|
8
|
|
|
t.column :auditable_type, :string |
|
9
|
|
|
t.column :associated_id, :integer |
|
10
|
|
|
t.column :associated_type, :string |
|
11
|
|
|
t.column :user_id, :integer |
|
12
|
|
|
t.column :user_type, :string |
|
13
|
|
|
t.column :username, :string |
|
14
|
|
|
t.column :action, :string |
|
15
|
|
|
t.column :audited_changes, :jsonb |
|
16
|
|
|
t.column :version, :integer, default: 0 |
|
17
|
|
|
t.column :comment, :string |
|
18
|
|
|
t.column :remote_address, :string |
|
19
|
|
|
t.column :request_uuid, :string |
|
20
|
|
|
t.column :created_at, :datetime |
|
21
|
|
|
end |
|
22
|
|
|
add_indexes |
|
23
|
|
|
end |
|
24
|
|
|
|
|
25
|
|
|
def add_indexes |
|
26
|
|
|
add_index :audits, %i[auditable_type auditable_id], name: 'auditable_index' |
|
27
|
|
|
add_index :audits, %i[associated_type associated_id], name: 'associated_index' |
|
28
|
|
|
add_index :audits, %i[user_id user_type], name: 'user_index' |
|
29
|
|
|
add_index :audits, :request_uuid |
|
30
|
|
|
add_index :audits, :created_at |
|
31
|
|
|
end |
|
32
|
|
|
end |
|
33
|
|
|
|