Skip to content

@xtandard/audit/drizzle/mysql

MySQL Drizzle table factories for the audit store: mysqlAuditTables() (or the per-table factories) puts the KV and event-log tables in your Drizzle schema and migrations. Schema-only.

import { … } from "@xtandard/audit/drizzle/mysql";
Name Summary
mysqlAuditEventsTable Build the events table: PRIMARY KEY (tenant, seq), UNIQUE (tenant, id) and (tenant, occurred_at, id) / (tenant, actor_id, …) / (tenant, action, …) indexes. The name defaults to "xtandard_audit_events".
mysqlAuditEventTargetsTable Build the event-targets table (one row per distinct event target), indexed on (tenant, type, target_id, seq) and (tenant, seq). The name defaults to "xtandard_audit_event_targets".
mysqlAuditTable Build the MySQL mysqlTable for the audit KV store: key varchar PRIMARY KEY (utf8mb4_bin), value json NOT NULL. The table name defaults to "xtandard_audit".
mysqlAuditTables All three tables with matching names: {name}, {name}_events, {name}_event_targets.
Name Summary
DrizzleAuditTables All three audit tables, as returned by pgAuditTables() / mysqlAuditTables() / sqliteAuditTables(). The keys match createDrizzleStorage’s options, so createDrizzleStorage({ db, ...tables }) works.
MysqlAuditTableOptions Options for mysqlAuditTable.
Name Summary
DrizzleEventsTable The native event-log table ({name}_events): one row per event, the full event in data plus the denormalized columns queries filter and sort on.
DrizzleEventTargetsTable The event-targets table ({name}_event_targets): one row per distinct event target.