feat: Audit log APIs (#6434)

- Adds the appropriate APIs for Audit Logs.

ref: #6015
This commit is contained in:
Vishnu Narayanan
2023-03-01 20:02:58 +05:30
committed by GitHub
parent daf17046e9
commit d870b0815a
21 changed files with 261 additions and 1 deletions

View 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