procbay-schema 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "procbay-schema",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "A set of utilities for managing Prisma database schemas, seeding, and maintenance operations for the Procure-to-Pay system",
5
5
  "main": "src/prisma/index.js",
6
6
  "type": "module",
@@ -0,0 +1,58 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The values [PENDING,RESPONDED] on the enum `RequestedCatalogueDetailsStatusEnum` will be removed. If these variants are still used in the database, this will fail.
5
+
6
+ */
7
+ -- CreateEnum
8
+ CREATE TYPE "CatalogueStatusEnum" AS ENUM ('ACTIVE', 'INACTIVE');
9
+
10
+ -- AlterEnum
11
+ BEGIN;
12
+ CREATE TYPE "RequestedCatalogueDetailsStatusEnum_new" AS ENUM ('REQUESTED', 'QUOTED', 'REJECTED', 'MARK_FOR_LATER');
13
+ ALTER TABLE "requested_catalogue_details" ALTER COLUMN "status" DROP DEFAULT;
14
+ ALTER TABLE "requested_catalogue_details" ALTER COLUMN "status" TYPE "RequestedCatalogueDetailsStatusEnum_new" USING ("status"::text::"RequestedCatalogueDetailsStatusEnum_new");
15
+ ALTER TYPE "RequestedCatalogueDetailsStatusEnum" RENAME TO "RequestedCatalogueDetailsStatusEnum_old";
16
+ ALTER TYPE "RequestedCatalogueDetailsStatusEnum_new" RENAME TO "RequestedCatalogueDetailsStatusEnum";
17
+ DROP TYPE "RequestedCatalogueDetailsStatusEnum_old";
18
+ ALTER TABLE "requested_catalogue_details" ALTER COLUMN "status" SET DEFAULT 'REQUESTED';
19
+ COMMIT;
20
+
21
+ -- AlterTable
22
+ ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
23
+
24
+ -- AlterTable
25
+ ALTER TABLE "requested_catalogue_details" ADD COLUMN "stock" INTEGER,
26
+ ADD COLUMN "unit_price" DECIMAL(15,2),
27
+ ALTER COLUMN "status" SET DEFAULT 'REQUESTED';
28
+
29
+ -- CreateTable
30
+ CREATE TABLE "catalogue" (
31
+ "id" SERIAL NOT NULL,
32
+ "uuid" TEXT NOT NULL,
33
+ "vendor_id" INTEGER,
34
+ "req_catalogue_id" INTEGER,
35
+ "item_id" INTEGER,
36
+ "variant_id" INTEGER,
37
+ "stock" INTEGER,
38
+ "price" DECIMAL(15,2),
39
+ "status" "CatalogueStatusEnum" NOT NULL DEFAULT 'ACTIVE',
40
+ "created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
41
+ "created_by" INTEGER,
42
+ "updated_at" TIMESTAMPTZ(6),
43
+ "updated_by" INTEGER,
44
+ "is_deleted" BOOLEAN DEFAULT false,
45
+ "deleted_at" TIMESTAMPTZ(6),
46
+ "deleted_by" INTEGER,
47
+
48
+ CONSTRAINT "catalogue_pkey" PRIMARY KEY ("id")
49
+ );
50
+
51
+ -- CreateIndex
52
+ CREATE UNIQUE INDEX "catalogue_uuid_key" ON "catalogue"("uuid");
53
+
54
+ -- AddForeignKey
55
+ ALTER TABLE "catalogue" ADD CONSTRAINT "catalogue_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE;
56
+
57
+ -- AddForeignKey
58
+ ALTER TABLE "catalogue" ADD CONSTRAINT "catalogue_variant_id_fkey" FOREIGN KEY ("variant_id") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,8 @@
1
+ -- AlterTable
2
+ ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "item" ADD COLUMN "sub_category_id" INTEGER;
6
+
7
+ -- AddForeignKey
8
+ ALTER TABLE "item" ADD CONSTRAINT "item_sub_category_id_fkey" FOREIGN KEY ("sub_category_id") REFERENCES "categories"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -238,25 +238,26 @@ model UserDepartment {
238
238
 
239
239
  //---------------------------------- CATEGORY MODEL START ----------------------------------
240
240
  model Category {
241
- id Int @id @default(autoincrement())
242
- uuid String? @unique @default(uuid())
243
- name String? @unique
244
- slug String?
245
- is_active Boolean @default(true)
246
- parent_id Int @default(0)
247
- description String?
248
- image_url String?
249
- created_by Int?
250
- created_at DateTime @default(now()) @db.Timestamptz(6)
251
- updated_by Int?
252
- updated_at DateTime @updatedAt @db.Timestamptz(6)
253
- is_deleted Boolean @default(false)
254
- deleted_by Int?
255
- deleted_at DateTime? @db.Timestamptz(6)
256
- attributes Attribute[]
257
- Item Item[]
258
- category_uom UomCategory[]
259
- category_budget CategoryBudget[]
241
+ id Int @id @default(autoincrement())
242
+ uuid String? @unique @default(uuid())
243
+ name String? @unique
244
+ slug String?
245
+ is_active Boolean @default(true)
246
+ parent_id Int @default(0)
247
+ description String?
248
+ image_url String?
249
+ created_by Int?
250
+ created_at DateTime @default(now()) @db.Timestamptz(6)
251
+ updated_by Int?
252
+ updated_at DateTime @updatedAt @db.Timestamptz(6)
253
+ is_deleted Boolean @default(false)
254
+ deleted_by Int?
255
+ deleted_at DateTime? @db.Timestamptz(6)
256
+ attributes Attribute[]
257
+ category_uom UomCategory[]
258
+ category_budget CategoryBudget[]
259
+ item_category Item[] @relation("ItemCategory")
260
+ item_sub_category Item[] @relation("ItemSubCategory")
260
261
 
261
262
  @@map("categories")
262
263
  }
@@ -320,7 +321,9 @@ model Item {
320
321
  is_parent Boolean @default(false)
321
322
  parent_id Int? @default(0)
322
323
  category_id Int?
323
- category Category? @relation(fields: [category_id], references: [id])
324
+ category Category? @relation("ItemCategory", fields: [category_id], references: [id])
325
+ sub_category_id Int?
326
+ sub_category Category? @relation("ItemSubCategory", fields: [sub_category_id], references: [id])
324
327
  uomId Int?
325
328
  uom Uom? @relation(fields: [uomId], references: [id])
326
329
  item_code String? @unique
@@ -387,6 +390,8 @@ model Item {
387
390
  purchase_order_items PurchaseOrderItem[]
388
391
  requested_catalogue_items RequestedCatalogueDetails[] @relation("ParentItemRequests")
389
392
  requested_catalogue_variants RequestedCatalogueDetails[] @relation("VariantItemRequests")
393
+ catalogue_items Catalogue[] @relation("ParentItemRequests")
394
+ catalogue_variants Catalogue[] @relation("VariantItemRequests")
390
395
 
391
396
  @@unique([item_handler, item_name])
392
397
  @@index([parent_id, is_active, is_deleted]) // For variant queries
@@ -2501,8 +2506,8 @@ model RequestedCatalogue {
2501
2506
  //------------------------------------- FAST CATALOGUE DETAILS MODEL START ----------------------------------------------
2502
2507
 
2503
2508
  enum RequestedCatalogueDetailsStatusEnum {
2504
- PENDING
2505
- RESPONDED
2509
+ REQUESTED
2510
+ QUOTED
2506
2511
  REJECTED
2507
2512
  MARK_FOR_LATER
2508
2513
  }
@@ -2517,7 +2522,9 @@ model RequestedCatalogueDetails {
2517
2522
  variant_id Int?
2518
2523
  variant Item? @relation("VariantItemRequests", fields: [variant_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
2519
2524
  vendor_id Int?
2520
- status RequestedCatalogueDetailsStatusEnum? @default(PENDING)
2525
+ status RequestedCatalogueDetailsStatusEnum? @default(REQUESTED)
2526
+ stock Int?
2527
+ unit_price Decimal? @db.Decimal(15, 2)
2521
2528
  created_at DateTime @default(now()) @db.Timestamptz(6)
2522
2529
  created_by Int?
2523
2530
  updated_at DateTime @updatedAt @db.Timestamptz(6)
@@ -2534,3 +2541,34 @@ model RequestedCatalogueDetails {
2534
2541
 
2535
2542
  //------------------------------------- FAST CATALOGUE DETAILS MODEL END --------------------------------------------------
2536
2543
 
2544
+ //---------------------------------- CATALOGUE MODEL START ---------------------------------------
2545
+
2546
+ enum CatalogueStatusEnum {
2547
+ ACTIVE
2548
+ INACTIVE
2549
+ }
2550
+
2551
+ model Catalogue {
2552
+ id Int @id @default(autoincrement())
2553
+ uuid String @unique @default(uuid())
2554
+ vendor_id Int?
2555
+ req_catalogue_id Int?
2556
+ item_id Int?
2557
+ parent_item Item? @relation("ParentItemRequests", fields: [item_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
2558
+ variant_id Int?
2559
+ variant Item? @relation("VariantItemRequests", fields: [variant_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
2560
+ stock Int?
2561
+ price Decimal? @db.Decimal(15, 2)
2562
+ status CatalogueStatusEnum @default(ACTIVE)
2563
+ created_at DateTime? @default(now()) @db.Timestamptz(6)
2564
+ created_by Int?
2565
+ updated_at DateTime? @updatedAt @db.Timestamptz(6)
2566
+ updated_by Int?
2567
+ is_deleted Boolean? @default(false)
2568
+ deleted_at DateTime? @db.Timestamptz(6)
2569
+ deleted_by Int?
2570
+
2571
+ @@map("catalogue")
2572
+ }
2573
+
2574
+ //---------------------------------- CATALOGUE MODEL END ---------------------------------------