45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import {
|
|
boolean,
|
|
integer,
|
|
jsonb,
|
|
pgTable,
|
|
text,
|
|
timestamp,
|
|
uniqueIndex,
|
|
uuid,
|
|
} from "drizzle-orm/pg-core";
|
|
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
|
import type z from "zod";
|
|
|
|
export const printerData = pgTable(
|
|
"printer_data",
|
|
{
|
|
id: uuid("id").defaultRandom().primaryKey(),
|
|
humanReadableId: text("humanReadable_id").unique().notNull(),
|
|
name: text("name").notNull(),
|
|
ipAddress: text("ipAddress"),
|
|
port: integer("port"),
|
|
status: text("status"),
|
|
statusText: text("statusText"),
|
|
printerSN: text("printer_sn"),
|
|
lastTimePrinted: timestamp("last_time_printed").notNull().defaultNow(),
|
|
assigned: boolean("assigned").default(false),
|
|
remark: text("remark"),
|
|
printDelay: integer("printDelay").default(90),
|
|
processes: jsonb("processes").default([]),
|
|
printDelayOverride: boolean("print_delay_override").default(false), // this will be more for if we have the lot time active but want to over ride this single line for some reason
|
|
add_Date: timestamp("add_Date").defaultNow(),
|
|
upd_date: timestamp("upd_date").defaultNow(),
|
|
},
|
|
(table) => [
|
|
//uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`),
|
|
uniqueIndex("printer_id").on(table.humanReadableId),
|
|
],
|
|
);
|
|
|
|
export const printerSchema = createSelectSchema(printerData);
|
|
export const newPrinterSchema = createInsertSchema(printerData);
|
|
|
|
export type Printer = z.infer<typeof printerSchema>;
|
|
export type NewPrinter = z.infer<typeof newPrinterSchema>;
|