feat: add user_stats, audit_logs and verification tokens schema
Made-with: Cursor
This commit is contained in:
18
src/db/schema/auditLogs.ts
Normal file
18
src/db/schema/auditLogs.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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<Record<string, unknown>>(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export type AuditLog = typeof auditLogs.$inferSelect;
|
||||
export type NewAuditLog = typeof auditLogs.$inferInsert;
|
||||
Reference in New Issue
Block a user