feat(forklifts): added backend forklift stuff and frontend companies
This commit is contained in:
52
app/src/pkg/db/schema/forklifts.ts
Normal file
52
app/src/pkg/db/schema/forklifts.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
integer,
|
||||
pgEnum,
|
||||
pgTable,
|
||||
serial,
|
||||
text,
|
||||
timestamp,
|
||||
uuid,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
import { leases } from "./forkliftLeases.js";
|
||||
import { serverData } from "./servers.js";
|
||||
|
||||
const status = pgEnum("forklift_status", [
|
||||
"active",
|
||||
"inactive",
|
||||
"sold",
|
||||
"retired",
|
||||
"transferred",
|
||||
]);
|
||||
|
||||
export const forklifts = pgTable("forklifts", {
|
||||
forklift_id: uuid("forklift_id").defaultRandom().primaryKey(),
|
||||
forkliftNumber: serial("forklift_number").notNull(),
|
||||
serialNumber: text("serial_number").notNull(),
|
||||
model: text("model").notNull(),
|
||||
plant: text("plant")
|
||||
.notNull()
|
||||
.references(() => serverData.name, { onDelete: "set null" }), // what plant the forklift is in.
|
||||
forkliftStatus: text("forklift_status").default("active"), //["active","inactive","sold","retired","transferred",]
|
||||
glCode: integer("gl_code").notNull(), // this will be updated on the onconflift update so we dont do anything funny.
|
||||
profitCenter: integer("profit_center").notNull(), // should be updated if its changing profit centers per request by the plant
|
||||
manufacturer: text("manufacturer").notNull(),
|
||||
manufacturerYear: text("manufacturer_year").notNull(),
|
||||
engine: text("engine").notNull(),
|
||||
batteryType: text("battery_type").notNull(),
|
||||
leaseId: uuid("lease_id").references(() => leases.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
dataPlate: text("data_plate"),
|
||||
add_date: timestamp("add_date").defaultNow(),
|
||||
add_user: text("add_user").default("LST"),
|
||||
upd_date: timestamp("add_date").defaultNow(),
|
||||
upd_user: text("add_user").default("LST"),
|
||||
});
|
||||
|
||||
export const forkliftsSchema = createSelectSchema(forklifts);
|
||||
export const newForkliftsSchema = createInsertSchema(forklifts);
|
||||
|
||||
export type Forklift = z.infer<typeof forkliftsSchema>;
|
||||
export type NewNewForklift = z.infer<typeof newForkliftsSchema>;
|
||||
Reference in New Issue
Block a user