import { pgTable, uuid, timestamp, text, bigint, boolean, jsonb, } from "drizzle-orm/pg-core" import { tenants } from "./tenants" import { vehicles } from "./vehicles" import { inventoryItems } from "./inventoryitems" import { authUsers } from "./auth_users" export const checks = pgTable("checks", { id: uuid("id").primaryKey().defaultRandom(), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .defaultNow(), vehicle: bigint("vehicle", { mode: "number" }) .references(() => vehicles.id), // ❌ profile removed (old 0_profiles reference) inventoryItem: bigint("inventoryitem", { mode: "number" }) .references(() => inventoryItems.id), tenant: bigint("tenant", { mode: "number" }) .references(() => tenants.id), name: text("name"), type: text("type"), distance: bigint("distance", { mode: "number" }).default(1), distanceUnit: text("distanceUnit").default("days"), description: text("description"), profiles: jsonb("profiles").notNull().default([]), archived: boolean("archived").notNull().default(false), updatedAt: timestamp("updated_at", { withTimezone: true }), updatedBy: uuid("updated_by").references(() => authUsers.id), }) export type Check = typeof checks.$inferSelect export type NewCheck = typeof checks.$inferInsert