diff options
Diffstat (limited to 'db/migrate/20190312193025_install_audited.rb')
-rw-r--r-- | db/migrate/20190312193025_install_audited.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20190312193025_install_audited.rb b/db/migrate/20190312193025_install_audited.rb new file mode 100644 index 0000000..ef5487e --- /dev/null +++ b/db/migrate/20190312193025_install_audited.rb | |||
@@ -0,0 +1,30 @@ | |||
1 | class InstallAudited < ActiveRecord::Migration[5.2] | ||
2 | def self.up | ||
3 | create_table :audits, :force => true do |t| | ||
4 | t.column :auditable_id, :integer | ||
5 | t.column :auditable_type, :string | ||
6 | t.column :associated_id, :integer | ||
7 | t.column :associated_type, :string | ||
8 | t.column :user_id, :integer | ||
9 | t.column :user_type, :string | ||
10 | t.column :username, :string | ||
11 | t.column :action, :string | ||
12 | t.column :audited_changes, :text | ||
13 | t.column :version, :integer, :default => 0 | ||
14 | t.column :comment, :string | ||
15 | t.column :remote_address, :string | ||
16 | t.column :request_uuid, :string | ||
17 | t.column :created_at, :datetime | ||
18 | end | ||
19 | |||
20 | add_index :audits, [:auditable_type, :auditable_id, :version], :name => 'auditable_index' | ||
21 | add_index :audits, [:associated_type, :associated_id], :name => 'associated_index' | ||
22 | add_index :audits, [:user_id, :user_type], :name => 'user_index' | ||
23 | add_index :audits, :request_uuid | ||
24 | add_index :audits, :created_at | ||
25 | end | ||
26 | |||
27 | def self.down | ||
28 | drop_table :audits | ||
29 | end | ||
30 | end | ||