import { pgTable, uuid, timestamp, text, boolean, jsonb, bigint, } from "drizzle-orm/pg-core" import { tenants } from "./tenants" import { inventoryItems } from "./inventoryitems" import { projects } from "./projects" import { vehicles } from "./vehicles" import { authUsers } from "./auth_users" export const costcentres = pgTable("costcentres", { id: uuid("id").primaryKey().defaultRandom(), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .defaultNow(), tenant: bigint("tenant", { mode: "number" }) .notNull() .references(() => tenants.id), number: text("number").notNull(), name: text("name").notNull(), vehicle: bigint("vehicle", { mode: "number" }).references(() => vehicles.id), project: bigint("project", { mode: "number" }).references(() => projects.id), inventoryitem: bigint("inventoryitem", { mode: "number" }).references( () => inventoryItems.id ), description: text("description"), archived: boolean("archived").notNull().default(false), profiles: jsonb("profiles").notNull().default([]), updatedAt: timestamp("updated_at", { withTimezone: true }), updatedBy: uuid("updated_by").references(() => authUsers.id), }) export type CostCentre = typeof costcentres.$inferSelect export type NewCostCentre = typeof costcentres.$inferInsert