feat: Audit log APIs (#6434)
- Adds the appropriate APIs for Audit Logs. ref: #6015
This commit is contained in:
34
db/migrate/20230202132107_install_audited.rb
Normal file
34
db/migrate/20230202132107_install_audited.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class InstallAudited < ActiveRecord::Migration[6.1]
|
||||
# rubocop:disable RMetrics/MethodLength
|
||||
def self.up
|
||||
create_table :audits, :force => true do |t|
|
||||
t.bigint :auditable_id
|
||||
t.string :auditable_type
|
||||
t.bigint :associated_id
|
||||
t.string :associated_type
|
||||
t.bigint :user_id
|
||||
t.string :user_type
|
||||
t.string :username
|
||||
t.string :action
|
||||
t.jsonb :audited_changes
|
||||
t.integer :version, :integer, :default => 0
|
||||
t.string :comment
|
||||
t.string :remote_address
|
||||
t.string :request_uuid
|
||||
t.datetime :created_at
|
||||
end
|
||||
# rubocop:enable RMetrics/MethodLength
|
||||
|
||||
add_index :audits, [:auditable_type, :auditable_id, :version], :name => 'auditable_index'
|
||||
add_index :audits, [:associated_type, :associated_id], :name => 'associated_index'
|
||||
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
||||
add_index :audits, :request_uuid
|
||||
add_index :audits, :created_at
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :audits
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user