fix(database): correction to the printer modules

This commit is contained in:
2025-04-04 17:08:25 -05:00
parent 16e5413a90
commit 8194798a37
20 changed files with 12720 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE "printers" ALTER COLUMN "lastTimePrinted" SET DATA TYPE timestamp;--> statement-breakpoint
ALTER TABLE "printers" ADD COLUMN "printDelay" numeric;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "printers" ALTER COLUMN "lastTimePrinted" SET DEFAULT now();--> statement-breakpoint
ALTER TABLE "printers" ALTER COLUMN "lastTimePrinted" SET NOT NULL;

View File

@@ -0,0 +1 @@
ALTER TABLE "printers" ALTER COLUMN "lastTimePrinted" SET DATA TYPE timestamp with time zone;

View File

@@ -0,0 +1 @@
ALTER TABLE "printers" DROP COLUMN "lastTimePrinted";

View File

@@ -0,0 +1 @@
ALTER TABLE "printers" DROP COLUMN "printDelay";

View File

@@ -0,0 +1,19 @@
CREATE TABLE "printerData" (
"printer_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"humanReadableId" text,
"name" text NOT NULL,
"ipAddress" text,
"port" numeric,
"status" text,
"statusText" text,
"lastTimePrinted" timestamp DEFAULT now() NOT NULL,
"assigned" boolean DEFAULT false,
"remark" text,
"printDelay" numeric,
"monitorState" boolean DEFAULT false,
"add_Date" timestamp DEFAULT now(),
"upd_date" timestamp DEFAULT now()
);
--> statement-breakpoint
DROP TABLE "printers" CASCADE;--> statement-breakpoint
CREATE UNIQUE INDEX "humanReadableId" ON "printerData" USING btree ("humanReadableId");

View File

@@ -0,0 +1,17 @@
CREATE TABLE "subModules" (
"submodule_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"moduleName" text NOT NULL,
"name" text NOT NULL,
"description" text,
"link" text NOT NULL,
"active" boolean DEFAULT false,
"roles" jsonb DEFAULT '["systemAdmin"]'::jsonb NOT NULL,
"subSubModule" jsonb DEFAULT '[]'::jsonb,
"add_User" text DEFAULT 'LST_System' NOT NULL,
"add_Date" timestamp DEFAULT now(),
"upd_User" text DEFAULT 'LST_System' NOT NULL,
"upd_date" timestamp DEFAULT now()
);
--> statement-breakpoint
ALTER TABLE "subModules" ADD CONSTRAINT "subModules_moduleName_modules_name_fk" FOREIGN KEY ("moduleName") REFERENCES "public"."modules"("name") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "subModule_name" ON "subModules" USING btree ("name");

View File

@@ -0,0 +1 @@
DROP INDEX "subModule_name";

View File

@@ -0,0 +1,3 @@
ALTER TABLE "subModules" DROP CONSTRAINT "subModules_moduleName_modules_name_fk";
--> statement-breakpoint
ALTER TABLE "subModules" ALTER COLUMN "moduleName" DROP NOT NULL;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -239,6 +239,69 @@
"when": 1743424730855, "when": 1743424730855,
"tag": "0033_flimsy_salo", "tag": "0033_flimsy_salo",
"breakpoints": true "breakpoints": true
},
{
"idx": 34,
"version": "7",
"when": 1743720994399,
"tag": "0034_massive_penance",
"breakpoints": true
},
{
"idx": 35,
"version": "7",
"when": 1743721140937,
"tag": "0035_even_adam_warlock",
"breakpoints": true
},
{
"idx": 36,
"version": "7",
"when": 1743721251498,
"tag": "0036_fixed_spacker_dave",
"breakpoints": true
},
{
"idx": 37,
"version": "7",
"when": 1743721424503,
"tag": "0037_cooing_orphan",
"breakpoints": true
},
{
"idx": 38,
"version": "7",
"when": 1743729665453,
"tag": "0038_lumpy_kitty_pryde",
"breakpoints": true
},
{
"idx": 39,
"version": "7",
"when": 1743771209867,
"tag": "0039_greedy_steve_rogers",
"breakpoints": true
},
{
"idx": 40,
"version": "7",
"when": 1743776921664,
"tag": "0040_luxuriant_aqueduct",
"breakpoints": true
},
{
"idx": 41,
"version": "7",
"when": 1743778410407,
"tag": "0041_wise_molten_man",
"breakpoints": true
},
{
"idx": 42,
"version": "7",
"when": 1743778477759,
"tag": "0042_big_power_pack",
"breakpoints": true
} }
] ]
} }

View File

@@ -11,8 +11,8 @@ import {
import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { z } from "zod"; import { z } from "zod";
export const printers = pgTable( export const printerData = pgTable(
"printers", "printerData",
{ {
printer_id: uuid("printer_id").defaultRandom().primaryKey(), printer_id: uuid("printer_id").defaultRandom().primaryKey(),
humanReadableId: text("humanReadableId"), humanReadableId: text("humanReadableId"),
@@ -21,9 +21,10 @@ export const printers = pgTable(
port: numeric("port"), port: numeric("port"),
status: text("status"), status: text("status"),
statusText: text("statusText"), statusText: text("statusText"),
lastTimePrinted: text("lastTimePrinted"), lastTimePrinted: timestamp("lastTimePrinted").notNull().defaultNow(),
assigned: boolean("assigned").default(false), assigned: boolean("assigned").default(false),
remark: text("remark"), remark: text("remark"),
printDelay: numeric("printDelay"),
monitorState: boolean("monitorState").default(false), monitorState: boolean("monitorState").default(false),
add_Date: timestamp("add_Date").defaultNow(), add_Date: timestamp("add_Date").defaultNow(),
upd_date: timestamp("upd_date").defaultNow(), upd_date: timestamp("upd_date").defaultNow(),
@@ -39,4 +40,4 @@ export const printers = pgTable(
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}), // name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
// }); // });
// Schema for selecting a Expenses - can be used to validate API responses // Schema for selecting a Expenses - can be used to validate API responses
export const selectRolesSchema = createSelectSchema(printers); export const selectRolesSchema = createSelectSchema(printerData);