import { pgTable, bigint, text, timestamp, boolean, jsonb, uuid, doublePrecision, } from "drizzle-orm/pg-core" import { tenants } from "./tenants" import { authUsers } from "./auth_users" export const vehicles = pgTable("vehicles", { id: bigint("id", { mode: "number" }) .primaryKey() .generatedByDefaultAsIdentity(), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .defaultNow(), tenant: bigint("tenant", { mode: "number" }) .notNull() .references(() => tenants.id), licensePlate: text("licensePlate"), name: text("name"), type: text("type"), active: boolean("active").default(true), // FIXED: driver references auth_users.id driver: uuid("driver").references(() => authUsers.id), vin: text("vin"), tankSize: doublePrecision("tankSize").notNull().default(0), archived: boolean("archived").notNull().default(false), buildYear: text("buildYear"), towingCapacity: bigint("towingCapacity", { mode: "number" }), powerInKW: bigint("powerInKW", { mode: "number" }), color: text("color"), profiles: jsonb("profiles").notNull().default([]), updatedAt: timestamp("updated_at", { withTimezone: true }), updatedBy: uuid("updated_by").references(() => authUsers.id), }) export type Vehicle = typeof vehicles.$inferSelect export type NewVehicle = typeof vehicles.$inferInsert