Files
compor-academy/server/migrations/005_audit_log.sql
Cauê Faleiros 3d4c72e85c
All checks were successful
CI / Validate frontend and API (push) Successful in 45s
CI / Build and publish Docker images (push) Successful in 24s
feat: improve learning and platform operations
2026-09-01 15:38:14 -03:00

14 lines
570 B
SQL

create table audit_logs (
id uuid primary key default gen_random_uuid(),
actor_id uuid references users(id) on delete set null,
action text not null check (char_length(action) between 1 and 120),
subject_type text not null check (char_length(subject_type) between 1 and 80),
subject_id uuid,
metadata jsonb not null default '{}'::jsonb,
ip_address inet,
created_at timestamptz not null default now()
);
create index audit_logs_created_index on audit_logs (created_at desc);
create index audit_logs_actor_index on audit_logs (actor_id, created_at desc);