export const trailers = createTable(
"trailer",
{
id: serial("id").primaryKey(),
registration: varchar("name", { length: 256 }).notNull(),
vin: varchar("vin", { length: 256 }).notNull(),
nextServiceDate: timestamp("next_service_date")
.default(sql`CURRENT_TIMESTAMP + INTERVAL '90 days'`)
.notNull(),
createdAt: timestamp("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt"),
},
(example) => ({
nameIndex: index("name_idx").on(example.registration),
}),
);
export const InspectionType = pgEnum("inspection_type", ["Hire", "Return"]);
export const inspections = createTable("inspection", {
id: serial("id").primaryKey(),
trailerId: integer("trailer_id").references(() => trailers.id),
trailerRegistration: varchar("trailer_registration", {
length: 256,
}).notNull(),
inspectionDate: timestamp("inspection_date")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
type: InspectionType("inspection_type").notNull(),
createdAt: timestamp("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt"),
});