feat(MED-85): create audit logs for medusa admin actions

This commit is contained in:
2025-08-25 11:51:35 +03:00
parent 811e860965
commit eb1eeb690b
2 changed files with 41 additions and 0 deletions

View File

@@ -174,6 +174,28 @@ export type Database = {
} }
Relationships: [] Relationships: []
} }
medusa_action: {
Row: {
id: number
medusa_user_id: string
user_email: string
action: string
page: string
created_at: string
}
Insert: {
medusa_user_id: string
user_email: string
action: string
page: string
}
Update: {
medusa_user_id?: string
user_email?: string
action?: string
page?: string
}
}
} }
Views: { Views: {
[_ in never]: never [_ in never]: never

View File

@@ -0,0 +1,19 @@
create table "audit"."medusa_action" (
"id" bigint generated by default as identity not null,
"medusa_user_id" text not null,
"user_email" text not null,
"action" text not null,
"page" text,
"created_at" timestamp with time zone not null default now()
);
grant usage on schema audit to authenticated;
grant select, insert, update, delete on table audit.medusa_action to authenticated;
alter table "audit"."medusa_action" enable row level security;
create policy "service_role_select" on "audit"."medusa_action" for select to service_role using (true);
create policy "service_role_insert" on "audit"."medusa_action" for insert to service_role with check (true);
create policy "service_role_update" on "audit"."medusa_action" for update to service_role using (true);
create policy "service_role_delete" on "audit"."medusa_action" for delete to service_role using (true);
grant select, insert, update, delete on table audit.medusa_action to service_role;