import { bigserial, text, timestamp, pgTable, bigint, index, } from "drizzle-orm/pg-core"; import { user } from "./users"; import { portfolio } from "./portfolio"; export const pibiRequests = pgTable( "pibi_requests", { id: bigserial("id", { mode: "bigint" }).primaryKey(), hubspotDealId: text("hubspot_deal_id").notNull(), portfolioId: bigint("portfolio_id", { mode: "bigint" }) .notNull() .references(() => portfolio.id), measureName: text("measure_name").notNull(), orderedAt: timestamp("ordered_at", { withTimezone: true }) .defaultNow() .notNull(), completedAt: timestamp("completed_at", { withTimezone: true }), createdByUserId: bigint("created_by_user_id", { mode: "bigint" }) .notNull() .references(() => user.id), pushedAt: timestamp("pushed_at", { withTimezone: true }), }, (table) => [ index("idx_pibi_requests_deal_id").on(table.hubspotDealId), index("idx_pibi_requests_portfolio_id").on(table.portfolioId), ], ); export type PibiRequest = typeof pibiRequests.$inferSelect; export type NewPibiRequest = typeof pibiRequests.$inferInsert;