import { date, integer, pgTable, text, timestamp, unique, uuid, } from "drizzle-orm/pg-core"; export const analyticsDaily = pgTable( "analytics_daily", { id: uuid("id").defaultRandom().primaryKey(), businessDate: date("business_date", { mode: "string" }).notNull(), method: text("method").notNull(), routePattern: text("route_pattern").notNull(), module: text("module").notNull(), totalHits: integer("total_hits").notNull(), uniqueUsers: integer("unique_users").notNull(), successCount: integer("success_count").notNull(), errorCount: integer("error_count").notNull(), avgDurationMs: integer("avg_duration_ms").notNull(), maxDurationMs: integer("max_duration_ms").notNull(), firstHitAt: timestamp("first_hit_at").notNull(), lastHitAt: timestamp("last_hit_at").notNull(), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), }, (table) => [ unique("analytics_daily_business_route_unique").on( table.businessDate, table.method, table.routePattern, table.module, ), ], );