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

View File

@@ -153,6 +153,28 @@ ActiveRecord::Schema.define(version: 2023_02_24_124632) do
t.index ["message_id"], name: "index_attachments_on_message_id"
end
create_table 'audits', force: :cascade 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', default: 0
t.string 'comment'
t.string 'remote_address'
t.string 'request_uuid'
t.datetime 'created_at'
t.index %w[associated_type associated_id], name: 'associated_index'
t.index %w[auditable_type auditable_id version], name: 'auditable_index'
t.index ['created_at'], name: 'index_audits_on_created_at'
t.index ['request_uuid'], name: 'index_audits_on_request_uuid'
t.index %w[user_id user_type], name: 'user_index'
end
create_table "automation_rules", force: :cascade do |t|
t.bigint "account_id", null: false
t.string "name", null: false