import { pgTable, uuid, varchar, timestamp } from 'drizzle-orm/pg-core'; import { jsonb } from 'drizzle-orm/pg-core'; import { users } from './users.js'; export const auditLogs = pgTable('audit_logs', { id: uuid('id').primaryKey().defaultRandom(), adminId: uuid('admin_id') .notNull() .references(() => users.id, { onDelete: 'cascade' }), action: varchar('action', { length: 100 }).notNull(), targetType: varchar('target_type', { length: 50 }).notNull(), targetId: uuid('target_id').notNull(), details: jsonb('details').$type>(), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), }); export type AuditLog = typeof auditLogs.$inferSelect; export type NewAuditLog = typeof auditLogs.$inferInsert;