procbay-schema 1.0.6 → 1.0.7

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.6",
3
+ "version": "1.0.7",
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,97 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "RequestedCatalogueStatusEnum" AS ENUM ('ACTIVE', 'COMPLETED');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "RequestedCatalogueItemStatusEnum" AS ENUM ('ACTIVE', 'INACTIVE');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "RequestedCatalogueVendorStatusEnum" AS ENUM ('PENDING', 'RESPONDED');
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "requested_catalogues" (
15
+ "id" SERIAL NOT NULL,
16
+ "uuid" TEXT,
17
+ "code" TEXT,
18
+ "status" "RequestedCatalogueStatusEnum" DEFAULT 'ACTIVE',
19
+ "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
20
+ "created_by" INTEGER,
21
+ "updated_at" TIMESTAMPTZ(6) NOT NULL,
22
+ "updated_by" INTEGER,
23
+ "is_deleted" BOOLEAN NOT NULL DEFAULT false,
24
+ "deleted_at" TIMESTAMPTZ(6),
25
+ "deleted_by" INTEGER,
26
+
27
+ CONSTRAINT "requested_catalogues_pkey" PRIMARY KEY ("id")
28
+ );
29
+
30
+ -- CreateTable
31
+ CREATE TABLE "requested_catalogue_items" (
32
+ "id" SERIAL NOT NULL,
33
+ "uuid" TEXT,
34
+ "req_catalogue_id" INTEGER,
35
+ "item_id" INTEGER,
36
+ "status" "RequestedCatalogueItemStatusEnum" DEFAULT 'ACTIVE',
37
+ "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
38
+ "created_by" INTEGER,
39
+ "updated_at" TIMESTAMPTZ(6) NOT NULL,
40
+ "updated_by" INTEGER,
41
+ "is_deleted" BOOLEAN NOT NULL DEFAULT false,
42
+ "deleted_at" TIMESTAMPTZ(6),
43
+ "deleted_by" INTEGER,
44
+
45
+ CONSTRAINT "requested_catalogue_items_pkey" PRIMARY KEY ("id")
46
+ );
47
+
48
+ -- CreateTable
49
+ CREATE TABLE "requested_catalogue_vendors" (
50
+ "id" SERIAL NOT NULL,
51
+ "uuid" TEXT,
52
+ "req_catalogue_id" INTEGER,
53
+ "vendor_id" INTEGER,
54
+ "status" "RequestedCatalogueVendorStatusEnum" DEFAULT 'PENDING',
55
+ "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
56
+ "created_by" INTEGER,
57
+ "updated_at" TIMESTAMPTZ(6) NOT NULL,
58
+ "updated_by" INTEGER,
59
+ "is_deleted" BOOLEAN NOT NULL DEFAULT false,
60
+ "deleted_at" TIMESTAMPTZ(6),
61
+ "deleted_by" INTEGER,
62
+
63
+ CONSTRAINT "requested_catalogue_vendors_pkey" PRIMARY KEY ("id")
64
+ );
65
+
66
+ -- CreateIndex
67
+ CREATE UNIQUE INDEX "requested_catalogues_uuid_key" ON "requested_catalogues"("uuid");
68
+
69
+ -- CreateIndex
70
+ CREATE UNIQUE INDEX "requested_catalogues_code_key" ON "requested_catalogues"("code");
71
+
72
+ -- CreateIndex
73
+ CREATE UNIQUE INDEX "requested_catalogue_items_uuid_key" ON "requested_catalogue_items"("uuid");
74
+
75
+ -- CreateIndex
76
+ CREATE INDEX "requested_catalogue_items_req_catalogue_id_idx" ON "requested_catalogue_items"("req_catalogue_id");
77
+
78
+ -- CreateIndex
79
+ CREATE INDEX "requested_catalogue_items_item_id_idx" ON "requested_catalogue_items"("item_id");
80
+
81
+ -- CreateIndex
82
+ CREATE UNIQUE INDEX "requested_catalogue_vendors_uuid_key" ON "requested_catalogue_vendors"("uuid");
83
+
84
+ -- CreateIndex
85
+ CREATE INDEX "requested_catalogue_vendors_req_catalogue_id_idx" ON "requested_catalogue_vendors"("req_catalogue_id");
86
+
87
+ -- CreateIndex
88
+ CREATE INDEX "requested_catalogue_vendors_vendor_id_idx" ON "requested_catalogue_vendors"("vendor_id");
89
+
90
+ -- AddForeignKey
91
+ ALTER TABLE "requested_catalogue_items" ADD CONSTRAINT "requested_catalogue_items_req_catalogue_id_fkey" FOREIGN KEY ("req_catalogue_id") REFERENCES "requested_catalogues"("id") ON DELETE CASCADE ON UPDATE CASCADE;
92
+
93
+ -- AddForeignKey
94
+ ALTER TABLE "requested_catalogue_items" ADD CONSTRAINT "requested_catalogue_items_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE;
95
+
96
+ -- AddForeignKey
97
+ ALTER TABLE "requested_catalogue_vendors" ADD CONSTRAINT "requested_catalogue_vendors_req_catalogue_id_fkey" FOREIGN KEY ("req_catalogue_id") REFERENCES "requested_catalogues"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -315,76 +315,77 @@ model AttributeValue {
315
315
 
316
316
  //---------------------------------- ITEM MODEL START ----------------------------------
317
317
  model Item {
318
- id Int @id @default(autoincrement())
319
- uuid String? @unique @default(uuid())
320
- is_parent Boolean @default(false)
321
- parent_id Int? @default(0)
318
+ id Int @id @default(autoincrement())
319
+ uuid String? @unique @default(uuid())
320
+ is_parent Boolean @default(false)
321
+ parent_id Int? @default(0)
322
322
  category_id Int?
323
- category Category? @relation(fields: [category_id], references: [id])
323
+ category Category? @relation(fields: [category_id], references: [id])
324
324
  uomId Int?
325
- uom Uom? @relation(fields: [uomId], references: [id])
326
- item_code String? @unique
325
+ uom Uom? @relation(fields: [uomId], references: [id])
326
+ item_code String? @unique
327
327
  item_name String?
328
328
  item_handler String?
329
- slug String? @unique
329
+ slug String? @unique
330
330
  description String?
331
331
  terms_and_conditions String[]
332
332
  keywords String[]
333
- tags Json? @db.JsonB
334
- cost_price Decimal? @default(0.00) @db.Decimal(10, 2)
335
- selling_price Decimal? @default(0.00) @db.Decimal(10, 2)
336
- profit Decimal? @default(0.00) @db.Decimal(10, 2)
337
- margin Decimal? @default(0.00) @db.Decimal(10, 2)
338
- title String? @db.VarChar(150)
339
- continue_selling_when_out_of_stock Boolean? @default(false)
340
- physical_product Boolean? @default(false)
341
- variant_attributes Json? @db.JsonB // {"color": "red", "size": "large", "material": "cotton"}
342
- variant_display_name String? @db.VarChar(200) // "Red Large Cotton" - auto-generated or custom
343
- available_qty Int? @default(0)
344
- inventory_reason String? @db.VarChar(150)
345
- reserved_quantity Int? @default(0)
346
- stock_in_hand Int? @default(0)
347
- reorder_level Int? @default(0) // NEW: When to reorder
333
+ tags Json? @db.JsonB
334
+ cost_price Decimal? @default(0.00) @db.Decimal(10, 2)
335
+ selling_price Decimal? @default(0.00) @db.Decimal(10, 2)
336
+ profit Decimal? @default(0.00) @db.Decimal(10, 2)
337
+ margin Decimal? @default(0.00) @db.Decimal(10, 2)
338
+ title String? @db.VarChar(150)
339
+ continue_selling_when_out_of_stock Boolean? @default(false)
340
+ physical_product Boolean? @default(false)
341
+ variant_attributes Json? @db.JsonB // {"color": "red", "size": "large", "material": "cotton"}
342
+ variant_display_name String? @db.VarChar(200) // "Red Large Cotton" - auto-generated or custom
343
+ available_qty Int? @default(0)
344
+ inventory_reason String? @db.VarChar(150)
345
+ reserved_quantity Int? @default(0)
346
+ stock_in_hand Int? @default(0)
347
+ reorder_level Int? @default(0) // NEW: When to reorder
348
348
  max_stock_level Int? // NEW: Maximum stock level
349
- sku String? @unique @db.VarChar(255)
350
- is_taxable Boolean? @default(false)
351
- bar_code String? @unique @db.VarChar(255) // Made unique
352
- physical_item Boolean? @default(false)
353
- track_quantity Boolean? @default(false)
354
- weight Decimal? @default(0.00) @db.Decimal(10, 2)
355
- dimensions Json? @db.JsonB // {"length": 10, "width": 5, "height": 2, "unit": "cm"}
356
- shipping_weight Decimal? @db.Decimal(10, 2) // Different from product weight
357
- media Json? @db.JsonB
358
- specifications Json? @db.JsonB
349
+ sku String? @unique @db.VarChar(255)
350
+ is_taxable Boolean? @default(false)
351
+ bar_code String? @unique @db.VarChar(255) // Made unique
352
+ physical_item Boolean? @default(false)
353
+ track_quantity Boolean? @default(false)
354
+ weight Decimal? @default(0.00) @db.Decimal(10, 2)
355
+ dimensions Json? @db.JsonB // {"length": 10, "width": 5, "height": 2, "unit": "cm"}
356
+ shipping_weight Decimal? @db.Decimal(10, 2) // Different from product weight
357
+ media Json? @db.JsonB
358
+ specifications Json? @db.JsonB
359
359
  template_suffix String?
360
360
  seo_page_title String?
361
361
  seo_meta_keyword String?
362
362
  seo_meta_description String?
363
- step_completed Int? @default(0)
364
- is_published Boolean? @default(false)
365
- published_at DateTime? @db.Timestamptz(6)
363
+ step_completed Int? @default(0)
364
+ is_published Boolean? @default(false)
365
+ published_at DateTime? @db.Timestamptz(6)
366
366
  published_by Int?
367
- is_active Boolean @default(true)
368
- is_featured Boolean @default(false) // NEW: For featured products
369
- is_default_variant Boolean @default(false) // NEW: Default variant for parent
370
- sort_order Int @default(0) // NEW: For ordering variants
371
- min_order_qty Int @default(1) // Minimum order quantity
367
+ is_active Boolean @default(true)
368
+ is_featured Boolean @default(false) // NEW: For featured products
369
+ is_default_variant Boolean @default(false) // NEW: Default variant for parent
370
+ sort_order Int @default(0) // NEW: For ordering variants
371
+ min_order_qty Int @default(1) // Minimum order quantity
372
372
  max_order_qty Int? // Maximum order quantity
373
- is_bulk_pricing_enabled Boolean @default(false) // For bulk pricing
374
- bulk_pricing_tiers Json? @db.JsonB // [{"qty": 10, "price": 20}, {"qty": 50, "price": 18}]
373
+ is_bulk_pricing_enabled Boolean @default(false) // For bulk pricing
374
+ bulk_pricing_tiers Json? @db.JsonB // [{"qty": 10, "price": 20}, {"qty": 50, "price": 18}]
375
375
  created_by Int?
376
- created_at DateTime @default(now()) @db.Timestamptz(6)
376
+ created_at DateTime @default(now()) @db.Timestamptz(6)
377
377
  updated_by Int?
378
- updated_at DateTime @updatedAt @db.Timestamptz(6)
379
- is_deleted Boolean @default(false)
378
+ updated_at DateTime @updatedAt @db.Timestamptz(6)
379
+ is_deleted Boolean @default(false)
380
380
  deleted_by Int?
381
- deleted_at DateTime? @db.Timestamptz(6)
381
+ deleted_at DateTime? @db.Timestamptz(6)
382
382
  purchase_intake_items PurchaseIntakeItem[]
383
383
  item_attributes ItemAttribute[]
384
384
  item_attribute_values ItemAttributeValue[]
385
385
  item_documents ItemDocument[]
386
386
  event_items EventItems[]
387
387
  purchase_order_items PurchaseOrderItem[]
388
+ requested_catalogue_item RequestedCatalogueItem[]
388
389
 
389
390
  @@unique([item_handler, item_name])
390
391
  @@index([parent_id, is_active, is_deleted]) // For variant queries
@@ -2452,3 +2453,88 @@ model VendorReference {
2452
2453
  }
2453
2454
 
2454
2455
  //------------------------------------- VENDOR REFERENCE MODEL END --------------------------------------------
2456
+
2457
+ //------------------------------------- FAST CATALOGUE MODEL START ----------------------------------------------
2458
+
2459
+ enum RequestedCatalogueStatusEnum {
2460
+ ACTIVE
2461
+ COMPLETED
2462
+ }
2463
+
2464
+ model RequestedCatalogue {
2465
+ id Int @id @default(autoincrement())
2466
+ uuid String? @unique @default(uuid())
2467
+ code String? @unique // Unique code for the catalogue
2468
+ status RequestedCatalogueStatusEnum? @default(ACTIVE)
2469
+ created_at DateTime @default(now()) @db.Timestamptz(6)
2470
+ created_by Int?
2471
+ updated_at DateTime @updatedAt @db.Timestamptz(6)
2472
+ updated_by Int?
2473
+ is_deleted Boolean @default(false)
2474
+ deleted_at DateTime? @db.Timestamptz(6)
2475
+ deleted_by Int?
2476
+ requested_catalogue_items RequestedCatalogueItem[]
2477
+ requested_catalogue_vendor RequestedCatalogueVendor[]
2478
+
2479
+ @@map("requested_catalogues")
2480
+ }
2481
+
2482
+ //------------------------------------- FAST CATALOGUE MODEL END ----------------------------------------------
2483
+
2484
+ //------------------------------------- FAST CATALOGUE ITEMS MODEL START ----------------------------------------------
2485
+
2486
+ enum RequestedCatalogueItemStatusEnum {
2487
+ ACTIVE
2488
+ INACTIVE
2489
+ }
2490
+
2491
+ model RequestedCatalogueItem {
2492
+ id Int @id @default(autoincrement())
2493
+ uuid String? @unique @default(uuid())
2494
+ req_catalogue_id Int?
2495
+ req_catalogue RequestedCatalogue? @relation(fields: [req_catalogue_id], references: [id], onDelete: Cascade)
2496
+ item_id Int?
2497
+ item Item? @relation(fields: [item_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
2498
+ status RequestedCatalogueItemStatusEnum? @default(ACTIVE)
2499
+ created_at DateTime @default(now()) @db.Timestamptz(6)
2500
+ created_by Int?
2501
+ updated_at DateTime @updatedAt @db.Timestamptz(6)
2502
+ updated_by Int?
2503
+ is_deleted Boolean @default(false)
2504
+ deleted_at DateTime? @db.Timestamptz(6)
2505
+ deleted_by Int?
2506
+
2507
+ @@index([req_catalogue_id])
2508
+ @@index([item_id])
2509
+ @@map("requested_catalogue_items")
2510
+ }
2511
+
2512
+ //------------------------------------- FAST CATALOGUE ITEMS MODEL END ----------------------------------------------
2513
+ //------------------------------------- FAST CATALOGUE VENDORS MODEL START ----------------------------------------------
2514
+
2515
+ enum RequestedCatalogueVendorStatusEnum {
2516
+ PENDING
2517
+ RESPONDED
2518
+ }
2519
+
2520
+ model RequestedCatalogueVendor {
2521
+ id Int @id @default(autoincrement())
2522
+ uuid String? @unique @default(uuid())
2523
+ req_catalogue_id Int?
2524
+ req_catalogue RequestedCatalogue? @relation(fields: [req_catalogue_id], references: [id], onDelete: Cascade)
2525
+ vendor_id Int?
2526
+ status RequestedCatalogueVendorStatusEnum? @default(PENDING)
2527
+ created_at DateTime @default(now()) @db.Timestamptz(6)
2528
+ created_by Int?
2529
+ updated_at DateTime @updatedAt @db.Timestamptz(6)
2530
+ updated_by Int?
2531
+ is_deleted Boolean @default(false)
2532
+ deleted_at DateTime? @db.Timestamptz(6)
2533
+ deleted_by Int?
2534
+
2535
+ @@index([req_catalogue_id])
2536
+ @@index([vendor_id])
2537
+ @@map("requested_catalogue_vendors")
2538
+ }
2539
+
2540
+ //------------------------------------- FAST CATALOGUE VENDORS MODEL END ----------------------------------------------