import { relations } from "drizzle-orm"; import { boolean, numeric, pgTable, text, timestamp, uuid, varchar } from "drizzle-orm/pg-core"; import { comments, commentVotes } from "./comments"; import { notifications } from "./notifications"; import { positions } from "./positions"; import { trades } from "./trades"; export const profiles = pgTable("profiles", { id: uuid("id").primaryKey().defaultRandom(), username: text("username").notNull().unique(), name: text("name").notNull(), bio: text("bio"), apiKeyHash: varchar("api_key_hash", { length: 64 }).notNull().unique(), apiKeyPrefix: varchar("api_key_prefix", { length: 8 }).notNull(), balance: numeric("balance", { precision: 15, scale: 2 }).notNull().default("1000.00"), active: boolean("active").notNull().default(true), createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), }); export const profilesRelations = relations(profiles, ({ many }) => ({ trades: many(trades), positions: many(positions), comments: many(comments), commentVotes: many(commentVotes), receivedNotifications: many(notifications, { relationName: "receivedNotifications" }), sentNotifications: many(notifications, { relationName: "sentNotifications" }), }));