diff --git a/.vscode/settings.json b/.vscode/settings.json index dac31fb..7fee58f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,12 @@ "source.fixAll.biome": "explicit", "source.organizeImports.biome": "explicit" }, - "cSpell.words": ["alpla", "alplamart", "alplaprod", "intiallally", "ppoo"] + "cSpell.words": [ + "alpla", + "alplamart", + "alplaprod", + "intiallally", + "ppoo", + "prodlabels" + ] } diff --git a/LogisticsSupportTool_API_DOCS/app/logistics/labeling/Preprint.bru b/LogisticsSupportTool_API_DOCS/app/logistics/labeling/Preprint.bru index 9b2931e..3d92168 100644 --- a/LogisticsSupportTool_API_DOCS/app/logistics/labeling/Preprint.bru +++ b/LogisticsSupportTool_API_DOCS/app/logistics/labeling/Preprint.bru @@ -18,7 +18,7 @@ body:json { "printerId": 7, // 457=22, 458=23 "layoutId": 25, "numberOfCopies": 0, - "qtyToPrint": 5 + "qtyToPrint": 1 } } diff --git a/LogisticsSupportTool_API_DOCS/environments/lst.bru b/LogisticsSupportTool_API_DOCS/environments/lst.bru index 04722d4..0ae2f52 100644 --- a/LogisticsSupportTool_API_DOCS/environments/lst.bru +++ b/LogisticsSupportTool_API_DOCS/environments/lst.bru @@ -1,5 +1,5 @@ vars { - url: https://usmcd1vms036.alpla.net + url: http://localhost:5500 session_cookie: urlv2: http://usmcd1vms036:3000 jwtV2: diff --git a/app/src/internal/logistics/controller/labeling/preprint.ts b/app/src/internal/logistics/controller/labeling/preprint.ts index a1ec20d..f99d3bb 100644 --- a/app/src/internal/logistics/controller/labeling/preprint.ts +++ b/app/src/internal/logistics/controller/labeling/preprint.ts @@ -8,10 +8,16 @@ * layout */ +import { eq } from "drizzle-orm"; +import type { Logger } from "pino"; +import { db } from "../../../../pkg/db/db.js"; +import { printers } from "../../../../pkg/db/schema/printers.js"; +import { prodlabels } from "../../../../pkg/db/schema/prodLabels.js"; import { createLogger } from "../../../../pkg/logger/logger.js"; import { delay } from "../../../../pkg/utils/delay.js"; +import { getMachineData } from "../../../../pkg/utils/getMachineInfo.js"; import { prodEndpoint } from "../../../../pkg/utils/prodEndpoint.js"; -import type { returnFunc } from "../../../../pkg/utils/return.js"; +import { tryCatch } from "../../../../pkg/utils/tryCatch.js"; export type Preprint = { scannerId: number; @@ -23,7 +29,49 @@ export type Preprint = { qtyToPrint: number; }; -export const preprintLabels = async (preprint: Preprint) => { +const addProdLabel = async ( + preprint: Preprint, + runningNr: number, + username: string, + log: Logger, +) => { + // get the printers + const printerName = await db + .select() + .from(printers) + .where(eq(printers.humanReadableId, preprint.printerId.toString())); + + // get the machine data + const { data, error } = await tryCatch(getMachineData("all")); + + if (error) { + log.error({ error: error }, "There was an error getting machine data"); + } + + const lineNumber = data.filter( + (n: any) => n.HumanReadableId === preprint.machineId, + ); + + const { data: prodLabel, error: prodLabelError } = await tryCatch( + db + .insert(prodlabels) + .values({ + printerID: preprint.printerId, + printerName: printerName[0]?.name, + runningNr: runningNr, + status: "printed", + line: lineNumber[0]?.Location || 0, + add_user: username, + }) + .onConflictDoNothing(), + ); + + if (prodLabelError) { + log.error({ error: error }, "Error adding the label"); + } +}; + +export const preprintLabels = async (preprint: Preprint, username?: string) => { const log = createLogger({ module: "logistics", subModule: "preprint", @@ -67,6 +115,13 @@ export const preprintLabels = async (preprint: Preprint) => { }; } labelsPrinted.push(parseInt(labels?.data.SSCC.slice(10, -1))); + // add the label to our label db for tracking purposes + addProdLabel( + preprint, + parseInt(labels?.data.SSCC.slice(10, -1)), + username || "lst", + log, + ); log.info( {}, `Label just created ${parseInt(labels?.data.SSCC.slice(10, -1))} and printed, remaining to print ${preprint.qtyToPrint - x}`, @@ -118,6 +173,12 @@ export const preprintLabels = async (preprint: Preprint) => { } labelsPrinted.push(parseInt(labels.data.SSCC.slice(10, -1))); + addProdLabel( + preprint, + parseInt(labels?.data.SSCC.slice(10, -1)), + username || "lst", + log, + ); log.info( {}, `Label just created ${parseInt(labels.data.SSCC.slice(10, -1))} and printed`, diff --git a/app/src/internal/logistics/routes/labeling/labelingRoutes.ts b/app/src/internal/logistics/routes/labeling/labelingRoutes.ts index 1b3c685..ac1fa59 100644 --- a/app/src/internal/logistics/routes/labeling/labelingRoutes.ts +++ b/app/src/internal/logistics/routes/labeling/labelingRoutes.ts @@ -1,8 +1,9 @@ import { Router } from "express"; +import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js"; import preprint from "./perprint.js"; const router = Router(); -router.use("/", preprint); +router.use("/", requireAuth(), preprint); export default router; diff --git a/app/src/internal/logistics/routes/labeling/perprint.ts b/app/src/internal/logistics/routes/labeling/perprint.ts index b728502..2272223 100644 --- a/app/src/internal/logistics/routes/labeling/perprint.ts +++ b/app/src/internal/logistics/routes/labeling/perprint.ts @@ -17,7 +17,7 @@ const router = Router(); router.post("/preprint", async (req: Request, res: Response) => { const parsed = Preprint.safeParse(req.body); - const print = await preprintLabels(req.body); + const print = await preprintLabels(req.body, req.user?.username || ""); res .status(200) diff --git a/app/src/internal/ocp/printers/printers.ts b/app/src/internal/ocp/printers/printers.ts index c025a83..9857268 100644 --- a/app/src/internal/ocp/printers/printers.ts +++ b/app/src/internal/ocp/printers/printers.ts @@ -1 +1,7 @@ -export const printers = () => {}; +import { updatePrinters } from "./updatePrinters.js"; + +export const printers = () => { + setTimeout(() => { + updatePrinters(); + }, 10 * 1000); +}; diff --git a/app/src/internal/ocp/printers/updatePrinters.ts b/app/src/internal/ocp/printers/updatePrinters.ts new file mode 100644 index 0000000..a7f3745 --- /dev/null +++ b/app/src/internal/ocp/printers/updatePrinters.ts @@ -0,0 +1,73 @@ +import { sql } from "drizzle-orm"; +import { db } from "../../../pkg/db/db.js"; +import { printers } from "../../../pkg/db/schema/printers.js"; +import { createLogger } from "../../../pkg/logger/logger.js"; +import { prodEndpoint } from "../../../pkg/utils/prodEndpoint.js"; +import { tryCatch } from "../../../pkg/utils/tryCatch.js"; + +export const updatePrinters = async () => { + const log = createLogger({ + module: "ocp", + subModule: "update Printers", + }); + const currentTime = new Date(Date.now()); + + const { data: prodPrinters, error: prodError } = await tryCatch( + prodEndpoint("GET", "/public/v1.0/Administration/Printers"), + ); + + if (prodError || prodPrinters?.data.length > 10000) { + //console.log(prodError); + return { + success: false, + message: "there was an error getting the printers.", + data: prodError, + }; + } + + // do the printer update into our db + const prodPrinterInfo = prodPrinters?.data; + + for (let i = 0; i < prodPrinterInfo.length; i++) { + const printerStuff: any = { + humanReadableId: prodPrinterInfo[i].humanReadableId, + name: prodPrinterInfo[i].name, + ipAddress: prodPrinterInfo[i].ipAddress, + port: prodPrinterInfo[i].port, + remark: prodPrinterInfo[i].remark, + processes: prodPrinterInfo[i].processes, + }; + const { data, error } = await tryCatch( + db + .insert(printers) + .values(printerStuff) + .onConflictDoUpdate({ + target: printers.humanReadableId, + set: { + //humanReadableId: prodPrinterInfo[i].humanReadableId, + name: prodPrinterInfo[i].name, + ipAddress: prodPrinterInfo[i].ipAddress, + port: prodPrinterInfo[i].port, + remark: prodPrinterInfo[i].remark, + processes: prodPrinterInfo[i].processes, + upd_date: sql`NOW()`, + //printDelay: "90", // need to remove in a couple weeks + }, + }), + ); + + if (error) { + log.error( + { error: error }, + `${ + prodPrinterInfo[i].name + } encoutered and error adding/updating ${JSON.stringify(error)}`, + ); + } + log.debug({}, `${prodPrinterInfo[i].name} were just added/updated.`); + } + + //await assignedPrinters(); + + return { success: true, message: "Printers were just added or updated." }; +}; diff --git a/app/src/pkg/db/schema/printers.ts b/app/src/pkg/db/schema/printers.ts new file mode 100644 index 0000000..f018457 --- /dev/null +++ b/app/src/pkg/db/schema/printers.ts @@ -0,0 +1,34 @@ +import { + boolean, + index, + jsonb, + numeric, + pgTable, + text, + timestamp, + uniqueIndex, + uuid, +} from "drizzle-orm/pg-core"; + +export const printers = pgTable( + "printers", + { + printer_id: uuid("printer_id").defaultRandom().primaryKey(), + humanReadableId: text("humanReadableId"), + name: text("name").notNull(), + ipAddress: text("ip_address"), + port: numeric("port"), + status: text("status"), + statusText: text("status_text"), + lastTimePrinted: timestamp("last_time_printed").notNull().defaultNow(), + assigned: boolean("assigned").default(false), + remark: text("remark"), + printDelay: numeric("print_delay").default("90"), + monitorState: boolean("monitor_state").default(false), + 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("humanReadableId").on(table.humanReadableId)], +); diff --git a/app/src/pkg/db/schema/prodLabels.ts b/app/src/pkg/db/schema/prodLabels.ts new file mode 100644 index 0000000..cd235cc --- /dev/null +++ b/app/src/pkg/db/schema/prodLabels.ts @@ -0,0 +1,27 @@ +import { + integer, + pgTable, + text, + timestamp, + uniqueIndex, + uuid, +} from "drizzle-orm/pg-core"; + +export const prodlabels = pgTable( + "prodlabels", + { + label_id: uuid("label_id").defaultRandom().primaryKey(), + printerID: integer("printerID"), + printerName: text("printerName"), + line: integer("line"), + runningNr: integer("runningNr").notNull(), + status: text("status"), // printed | bookedIn | delivered | booked out + add_user: text("add_user").default("lst"), + add_date: timestamp("add_date").defaultNow(), + upd_date: timestamp("upd_date").defaultNow(), + }, + (table) => [ + //uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`), + uniqueIndex("runningNr").on(table.runningNr), + ], +); diff --git a/app/src/pkg/prodSql/querys/general/machineInfo.ts b/app/src/pkg/prodSql/querys/general/machineInfo.ts new file mode 100644 index 0000000..cb45139 --- /dev/null +++ b/app/src/pkg/prodSql/querys/general/machineInfo.ts @@ -0,0 +1,9 @@ +export const machineCheck = ` + SELECT [HumanReadableId] + ,[Name] + ,[Location] + ,[Active] + ,[ImportSource] + ,[StagingMainMaterialMandatory] + FROM [test1_AlplaPROD2.0_Read].[masterData].[Machine] (nolock) + where Active = 1 and [Location] = [loc]`; diff --git a/app/src/pkg/utils/getMachineInfo.ts b/app/src/pkg/utils/getMachineInfo.ts new file mode 100644 index 0000000..274e62d --- /dev/null +++ b/app/src/pkg/utils/getMachineInfo.ts @@ -0,0 +1,29 @@ +import { createLogger } from "../logger/logger.js"; +import { prodQuery } from "../prodSql/prodQuery.js"; +import { machineCheck } from "../prodSql/querys/general/machineInfo.js"; + +export const getMachineData = async (machine: string) => { + const log = createLogger({ + module: "logistics", + subModule: "preprint", + }); + let updateQuery = machineCheck.replaceAll("[loc]", machine!); + + if (machine === "all") { + updateQuery = machineCheck.replaceAll("and [Location] = [loc]", ""); + } + + // create blank lots in case there is an error and dose not work + let mac = []; + + try { + const getMac: any = await prodQuery(updateQuery, "Machine id check"); + + mac = getMac.data; + // console.log("Machine data", mac); // removed due to swr being activated + } catch (err) { + log.error({ error: err }, `Error with Machine id Check query: ${err}`); + } + + return mac; +}; diff --git a/migrations/0020_conscious_hairball.sql b/migrations/0020_conscious_hairball.sql new file mode 100644 index 0000000..6fddf5c --- /dev/null +++ b/migrations/0020_conscious_hairball.sql @@ -0,0 +1,33 @@ +CREATE TABLE "printers" ( + "printer_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "humanReadableId" text, + "name" text NOT NULL, + "ip_address" text, + "port" numeric, + "status" text, + "status_text" text, + "last_time_printed" timestamp DEFAULT now() NOT NULL, + "assigned" boolean DEFAULT false, + "remark" text, + "print_delay" numeric DEFAULT '90', + "monitor_state" boolean DEFAULT false, + "processes" jsonb DEFAULT '[]'::jsonb, + "print_delay_override" boolean DEFAULT false, + "add_Date" timestamp DEFAULT now(), + "upd_date" timestamp DEFAULT now() +); +--> statement-breakpoint +CREATE TABLE "prodlabels" ( + "label_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "printerID" integer, + "printerName" text, + "line" integer, + "runningNr" integer NOT NULL, + "status" text, + "add_user" text DEFAULT 'lst', + "add_date" timestamp DEFAULT now(), + "upd_date" timestamp DEFAULT now() +); +--> statement-breakpoint +CREATE UNIQUE INDEX "humanReadableId" ON "printers" USING btree ("humanReadableId");--> statement-breakpoint +CREATE UNIQUE INDEX "runningNr" ON "prodlabels" USING btree ("runningNr"); \ No newline at end of file diff --git a/migrations/meta/0020_snapshot.json b/migrations/meta/0020_snapshot.json new file mode 100644 index 0000000..d3fa063 --- /dev/null +++ b/migrations/meta/0020_snapshot.json @@ -0,0 +1,1573 @@ +{ + "id": "434e402a-a38c-434e-aa71-b54d36c6d7b0", + "prevId": "393b94ef-0a76-4554-8db0-cffe14f8a3e8", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apiHits": { + "name": "apiHits", + "schema": "", + "columns": { + "apiHit_id": { + "name": "apiHit_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.apikey": { + "name": "apikey", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refill_interval": { + "name": "refill_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "refill_amount": { + "name": "refill_amount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 86400000 + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 10 + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "remaining": { + "name": "remaining", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "apikey_user_id_user_id_fk": { + "name": "apikey_user_id_user_id_fk", + "tableFrom": "apikey", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.jwks": { + "name": "jwks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "display_username": { + "name": "display_username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_login": { + "name": "last_login", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "user_username_unique": { + "name": "user_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "log_id": { + "name": "log_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subModule": { + "name": "subModule", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stack": { + "name": "stack", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.orderScheduler": { + "name": "orderScheduler", + "schema": "", + "columns": { + "schedule_id": { + "name": "schedule_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "av": { + "name": "av", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_type": { + "name": "order_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "order_number": { + "name": "order_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "header": { + "name": "header", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "line_item_number": { + "name": "line_item_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer_release_number": { + "name": "customer_release_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivery_date": { + "name": "delivery_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "loading_date": { + "name": "loading_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "order_qty": { + "name": "order_qty", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "order_lu": { + "name": "order_lu", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "delivered_qty": { + "name": "delivered_qty", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "delivered_lu": { + "name": "delivered_lu", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_as_EDI": { + "name": "created_as_EDI", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "current_state": { + "name": "current_state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "lst_date_check": { + "name": "lst_date_check", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "customer_address_id": { + "name": "customer_address_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "customer_description": { + "name": "customer_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dock": { + "name": "dock", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_from": { + "name": "order_from", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "orderNumber": { + "name": "orderNumber", + "columns": [ + { + "expression": "order_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printers": { + "name": "printers", + "schema": "", + "columns": { + "printer_id": { + "name": "printer_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "humanReadableId": { + "name": "humanReadableId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "port": { + "name": "port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status_text": { + "name": "status_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_time_printed": { + "name": "last_time_printed", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned": { + "name": "assigned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "print_delay": { + "name": "print_delay", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'90'" + }, + "monitor_state": { + "name": "monitor_state", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "processes": { + "name": "processes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "print_delay_override": { + "name": "print_delay_override", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "humanReadableId": { + "name": "humanReadableId", + "columns": [ + { + "expression": "humanReadableId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodlabels": { + "name": "prodlabels", + "schema": "", + "columns": { + "label_id": { + "name": "label_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "printerID": { + "name": "printerID", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "printerName": { + "name": "printerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "line": { + "name": "line", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "runningNr": { + "name": "runningNr", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst'" + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "runningNr": { + "name": "runningNr", + "columns": [ + { + "expression": "runningNr", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prodPermissions": { + "name": "prodPermissions", + "schema": "", + "columns": { + "prodPerm_id": { + "name": "prodPerm_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "rolesLegacy": { + "name": "rolesLegacy", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "prodPermName": { + "name": "prodPermName", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.serverData": { + "name": "serverData", + "schema": "", + "columns": { + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "serverDNS": { + "name": "serverDNS", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plantToken": { + "name": "plantToken", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "greatPlainsPlantCode": { + "name": "greatPlainsPlantCode", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "streetAddress": { + "name": "streetAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cityState": { + "name": "cityState", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zipcode": { + "name": "zipcode", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "contactEmail": { + "name": "contactEmail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPhone": { + "name": "contactPhone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customerTiAcc": { + "name": "customerTiAcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lstServerPort": { + "name": "lstServerPort", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "serverLoc": { + "name": "serverLoc", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lastUpdated": { + "name": "lastUpdated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "isUpgrading": { + "name": "isUpgrading", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst_user'" + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst_user'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "plantToken": { + "name": "plantToken", + "columns": [ + { + "expression": "plantToken", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.serverStats": { + "name": "serverStats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "'serverStats'" + }, + "build": { + "name": "build", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "lastUpdate": { + "name": "lastUpdate", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "settings_id": { + "name": "settings_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moduleName": { + "name": "moduleName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "add_User": { + "name": "add_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_User": { + "name": "upd_User", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'LST_System'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "name": { + "name": "name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_roles": { + "name": "user_roles", + "schema": "", + "columns": { + "user_role_id": { + "name": "user_role_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "unique_user_module": { + "name": "unique_user_module", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_roles_user_id_user_id_fk": { + "name": "user_roles_user_id_user_id_fk", + "tableFrom": "user_roles", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index ee64abb..f0756ae 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -141,6 +141,13 @@ "when": 1760623729227, "tag": "0019_bizarre_tarot", "breakpoints": true + }, + { + "idx": 20, + "version": "7", + "when": 1760703799708, + "tag": "0020_conscious_hairball", + "breakpoints": true } ] } \ No newline at end of file