feat: add user_stats, audit_logs and verification tokens schema

Made-with: Cursor
This commit is contained in:
Anton
2026-03-04 13:38:46 +03:00
parent 970a864823
commit ed8658916c
5 changed files with 87 additions and 0 deletions

View 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;