procbay-schema 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
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,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
@@ -0,0 +1,42 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[uuid]` on the table `budgets` will be added. If there are existing duplicate values, this will fail.
5
+ - A unique constraint covering the columns `[uuid]` on the table `category_budgets` will be added. If there are existing duplicate values, this will fail.
6
+ - A unique constraint covering the columns `[uuid]` on the table `department_budgets` will be added. If there are existing duplicate values, this will fail.
7
+ - A unique constraint covering the columns `[uuid]` on the table `expenses` will be added. If there are existing duplicate values, this will fail.
8
+ - A unique constraint covering the columns `[uuid]` on the table `supporting_documents` will be added. If there are existing duplicate values, this will fail.
9
+
10
+ */
11
+ -- AlterTable
12
+ ALTER TABLE "budgets" ADD COLUMN "uuid" TEXT;
13
+
14
+ -- AlterTable
15
+ ALTER TABLE "category_budgets" ADD COLUMN "uuid" TEXT;
16
+
17
+ -- AlterTable
18
+ ALTER TABLE "department_budgets" ADD COLUMN "uuid" TEXT;
19
+
20
+ -- AlterTable
21
+ ALTER TABLE "expenses" ADD COLUMN "uuid" TEXT;
22
+
23
+ -- AlterTable
24
+ ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
25
+
26
+ -- AlterTable
27
+ ALTER TABLE "supporting_documents" ADD COLUMN "uuid" TEXT;
28
+
29
+ -- CreateIndex
30
+ CREATE UNIQUE INDEX "budgets_uuid_key" ON "budgets"("uuid");
31
+
32
+ -- CreateIndex
33
+ CREATE UNIQUE INDEX "category_budgets_uuid_key" ON "category_budgets"("uuid");
34
+
35
+ -- CreateIndex
36
+ CREATE UNIQUE INDEX "department_budgets_uuid_key" ON "department_budgets"("uuid");
37
+
38
+ -- CreateIndex
39
+ CREATE UNIQUE INDEX "expenses_uuid_key" ON "expenses"("uuid");
40
+
41
+ -- CreateIndex
42
+ CREATE UNIQUE INDEX "supporting_documents_uuid_key" ON "supporting_documents"("uuid");
@@ -0,0 +1,14 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[code]` on the table `department_budgets` will be added. If there are existing duplicate values, this will fail.
5
+
6
+ */
7
+ -- AlterTable
8
+ ALTER TABLE "department_budgets" ADD COLUMN "code" TEXT;
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
12
+
13
+ -- CreateIndex
14
+ CREATE UNIQUE INDEX "department_budgets_code_key" ON "department_budgets"("code");
@@ -40,64 +40,64 @@ enum StatusEnum {
40
40
  }
41
41
 
42
42
  model User {
43
- id Int @id @default(autoincrement())
44
- uuid String? @unique @default(uuid())
45
- unique_id String? @unique
46
- name String?
47
- first_name String?
48
- middle_name String?
49
- last_name String?
50
- email_id String? @unique
51
- password String?
52
- country_code String?
53
- mobile_number String? @unique
54
- status StatusEnum @default(InActive)
55
- is_email_verified Boolean @default(false)
56
- is_mobile_verified Boolean @default(false)
57
- profile_picture String?
58
- invitation_status Boolean @default(false)
59
- reset_token String?
60
- reset_token_expiry DateTime? @db.Timestamptz(6)
61
- access_token_expiry String?
62
- token_version Int? @default(0) // This will be used to invalidate old refresh tokens
63
- is_logged_in Boolean @default(false)
64
- created_at DateTime @default(now()) @db.Timestamptz(6)
65
- created_by Int?
66
- updated_at DateTime? @updatedAt @db.Timestamptz(6)
67
- updated_by Int?
68
- is_deleted Boolean @default(false)
69
- deleted_at DateTime? @db.Timestamptz(6)
70
- deleted_by Int?
71
- user_roles UserRole[]
72
- user_department UserDepartment[]
73
- approval_hierarchy ApprovalHierarchy[]
74
- approval_journey ApprovalJourney[]
75
- approval_level_escalation ApprovalLevelEscalation[]
76
- ticket_replies TicketReply[] @relation("user_reply")
77
- ticket_assignment_by TicketAssignment[] @relation("user_assigned_by")
78
- ticket_assignment_to TicketAssignment[] @relation("user_assigned_to")
79
- ticket_assignment_by_user TicketHistory[] @relation("user_assigned_by")
80
- ticket_assignment_to_user TicketHistory[] @relation("user_assigned_to")
81
- admin_alerts AdminAlert[]
82
- purchase_intake PurchaseIntake[]
83
- approval_level_user ApprovalLevelUser[]
84
- approval_level_escalation_user ApprovalLevelEscalationUser[]
85
- purchase_intake_deleted_by PurchaseIntake[] @relation("purchase_intake_deleted_by")
86
- template Template[]
87
- event Event[]
88
- form_master FormMaster[]
89
- dynamic_form DynamicForm[]
90
- purchase_order PurchaseOrder[]
91
- purchase_order_activity_log PurchaseOrderActivityLog[]
92
- user_socket_tokens UserVendorSocketTokens[]
93
- activity_logs ActivityLog[]
94
- contact_us ContactUs[]
95
- upload_logs UploadLog[]
96
- chat_thread ChatThread[]
97
- export_logs ExportLog[]
98
- department_head Department[] @relation("department_head")
99
- budget_manager Department[] @relation("budget_manager")
100
- vendor_reference VendorReference[]
43
+ id Int @id @default(autoincrement())
44
+ uuid String? @unique @default(uuid())
45
+ unique_id String? @unique
46
+ name String?
47
+ first_name String?
48
+ middle_name String?
49
+ last_name String?
50
+ email_id String? @unique
51
+ password String?
52
+ country_code String?
53
+ mobile_number String? @unique
54
+ status StatusEnum @default(InActive)
55
+ is_email_verified Boolean @default(false)
56
+ is_mobile_verified Boolean @default(false)
57
+ profile_picture String?
58
+ invitation_status Boolean @default(false)
59
+ reset_token String?
60
+ reset_token_expiry DateTime? @db.Timestamptz(6)
61
+ access_token_expiry String?
62
+ token_version Int? @default(0) // This will be used to invalidate old refresh tokens
63
+ is_logged_in Boolean @default(false)
64
+ created_at DateTime @default(now()) @db.Timestamptz(6)
65
+ created_by Int?
66
+ updated_at DateTime? @updatedAt @db.Timestamptz(6)
67
+ updated_by Int?
68
+ is_deleted Boolean @default(false)
69
+ deleted_at DateTime? @db.Timestamptz(6)
70
+ deleted_by Int?
71
+ user_roles UserRole[]
72
+ user_department UserDepartment[]
73
+ approval_hierarchy ApprovalHierarchy[]
74
+ approval_journey ApprovalJourney[]
75
+ approval_level_escalation ApprovalLevelEscalation[]
76
+ ticket_replies TicketReply[] @relation("user_reply")
77
+ ticket_assignment_by TicketAssignment[] @relation("user_assigned_by")
78
+ ticket_assignment_to TicketAssignment[] @relation("user_assigned_to")
79
+ ticket_assignment_by_user TicketHistory[] @relation("user_assigned_by")
80
+ ticket_assignment_to_user TicketHistory[] @relation("user_assigned_to")
81
+ admin_alerts AdminAlert[]
82
+ purchase_intake PurchaseIntake[]
83
+ approval_level_user ApprovalLevelUser[]
84
+ approval_level_escalation_user ApprovalLevelEscalationUser[]
85
+ purchase_intake_deleted_by PurchaseIntake[] @relation("purchase_intake_deleted_by")
86
+ template Template[]
87
+ event Event[]
88
+ form_master FormMaster[]
89
+ dynamic_form DynamicForm[]
90
+ purchase_order PurchaseOrder[]
91
+ purchase_order_activity_log PurchaseOrderActivityLog[]
92
+ user_socket_tokens UserVendorSocketTokens[]
93
+ activity_logs ActivityLog[]
94
+ contact_us ContactUs[]
95
+ upload_logs UploadLog[]
96
+ chat_thread ChatThread[]
97
+ export_logs ExportLog[]
98
+ department_head Department[] @relation("department_head")
99
+ budget_manager Department[] @relation("budget_manager")
100
+ vendor_reference VendorReference[]
101
101
 
102
102
  @@map("users")
103
103
  }
@@ -238,25 +238,25 @@ 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
+ Item Item[]
258
+ category_uom UomCategory[]
259
+ category_budget CategoryBudget[]
260
260
 
261
261
  @@map("categories")
262
262
  }
@@ -981,42 +981,42 @@ enum EventPhase {
981
981
  }
982
982
 
983
983
  model Event {
984
- id Int @id @default(autoincrement())
985
- uuid String? @unique @default(uuid())
986
- code String? @unique
987
- template_id Int?
988
- template Template? @relation(fields: [template_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
989
- type EventType?
990
- name String?
991
- start_date DateTime? @db.Timestamptz(6) // Explicitly use timestamptz
992
- end_date DateTime? @db.Timestamptz(6) // Explicitly use timestamptz
993
- duration String?
994
- attachments Json?
995
- terms_conditions String?
996
- step_completed Int?
997
- status EventStatus? @default(Draft)
998
- event_phase EventPhase?
999
- purchase_intake_id Int?
1000
- purchase_intake PurchaseIntake? @relation(fields: [purchase_intake_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1001
- created_at DateTime? @default(now()) @db.Timestamptz(6)
1002
- created_by Int?
1003
- user User? @relation(fields: [created_by], references: [id], onDelete: Cascade)
1004
- updated_at DateTime? @updatedAt @db.Timestamptz(6)
1005
- updated_by Int?
1006
- is_deleted Boolean? @default(false)
1007
- reason String?
1008
- is_published Boolean @default(false)
1009
- deleted_at DateTime? @db.Timestamptz(6)
1010
- deleted_by Int?
1011
- event_items EventItems[]
1012
- event_vendors EventVendors[]
1013
- event_configurations EventConfigurations[]
1014
- event_strategies EventStrategies[]
1015
- bids Bid[]
1016
- bid_logs BidLog[]
1017
- quotations Quotation[]
1018
- quotation_logs QuotationLog[]
1019
- purchase_order PurchaseOrder[]
984
+ id Int @id @default(autoincrement())
985
+ uuid String? @unique @default(uuid())
986
+ code String? @unique
987
+ template_id Int?
988
+ template Template? @relation(fields: [template_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
989
+ type EventType?
990
+ name String?
991
+ start_date DateTime? @db.Timestamptz(6) // Explicitly use timestamptz
992
+ end_date DateTime? @db.Timestamptz(6) // Explicitly use timestamptz
993
+ duration String?
994
+ attachments Json?
995
+ terms_conditions String?
996
+ step_completed Int?
997
+ status EventStatus? @default(Draft)
998
+ event_phase EventPhase?
999
+ purchase_intake_id Int?
1000
+ purchase_intake PurchaseIntake? @relation(fields: [purchase_intake_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1001
+ created_at DateTime? @default(now()) @db.Timestamptz(6)
1002
+ created_by Int?
1003
+ user User? @relation(fields: [created_by], references: [id], onDelete: Cascade)
1004
+ updated_at DateTime? @updatedAt @db.Timestamptz(6)
1005
+ updated_by Int?
1006
+ is_deleted Boolean? @default(false)
1007
+ reason String?
1008
+ is_published Boolean @default(false)
1009
+ deleted_at DateTime? @db.Timestamptz(6)
1010
+ deleted_by Int?
1011
+ event_items EventItems[]
1012
+ event_vendors EventVendors[]
1013
+ event_configurations EventConfigurations[]
1014
+ event_strategies EventStrategies[]
1015
+ bids Bid[]
1016
+ bid_logs BidLog[]
1017
+ quotations Quotation[]
1018
+ quotation_logs QuotationLog[]
1019
+ purchase_order PurchaseOrder[]
1020
1020
 
1021
1021
  @@map("events")
1022
1022
  }
@@ -2293,6 +2293,7 @@ enum BudgetStatus {
2293
2293
 
2294
2294
  model Budget {
2295
2295
  id Int @id @default(autoincrement())
2296
+ uuid String? @unique @default(uuid())
2296
2297
  company_name String?
2297
2298
  fiscal_year String?
2298
2299
  currency String? @default("INR")
@@ -2319,6 +2320,8 @@ model Budget {
2319
2320
  //------------------------------------- DEPARTMENT BUDGET MODEL START --------------------------------------------
2320
2321
  model DepartmentBudget {
2321
2322
  id Int @id @default(autoincrement())
2323
+ uuid String? @unique @default(uuid())
2324
+ code String? @unique // Unique code for the department budget
2322
2325
  budget_id Int?
2323
2326
  department_id Int?
2324
2327
  allocated_budget Decimal? @db.Decimal(15, 2)
@@ -2348,6 +2351,7 @@ model DepartmentBudget {
2348
2351
  //------------------------------------- CATEGORY BUDGET MODEL START --------------------------------------------
2349
2352
  model CategoryBudget {
2350
2353
  id Int @id @default(autoincrement())
2354
+ uuid String? @unique @default(uuid())
2351
2355
  department_budget_id Int?
2352
2356
  category_id Int?
2353
2357
  allocated_budget Decimal @db.Decimal(15, 2)
@@ -2376,6 +2380,7 @@ model CategoryBudget {
2376
2380
 
2377
2381
  model SupportingDocument {
2378
2382
  id Int @id @default(autoincrement())
2383
+ uuid String? @unique @default(uuid())
2379
2384
  budget_id Int?
2380
2385
  department_budget_id Int?
2381
2386
  category_budget_id Int?
@@ -2406,6 +2411,7 @@ model SupportingDocument {
2406
2411
  // For tracking actual expenses against budgets
2407
2412
  model Expense {
2408
2413
  id Int @id @default(autoincrement())
2414
+ uuid String? @unique @default(uuid())
2409
2415
  category_budget_id Int?
2410
2416
  amount Decimal @db.Decimal(15, 2)
2411
2417
  description String?
@@ -2433,7 +2439,7 @@ model VendorReference {
2433
2439
  invited_by Int? // who invited the vendor to the tenant
2434
2440
  user User? @relation(fields: [invited_by], references: [id], onDelete: Cascade)
2435
2441
  invited_on DateTime?
2436
- meta_data Json? // Additional metadata about the vendor
2442
+ meta_data Json? // Additional metadata about the vendor
2437
2443
  is_deleted Boolean @default(false)
2438
2444
  created_at DateTime @default(now())
2439
2445
  created_by Int?
@@ -39,6 +39,7 @@ export async function seedTemplates(prismaClient) {
39
39
  field_name: field.field_name,
40
40
  }, // Use a unique identifier for fields
41
41
  data: {
42
+ field_slug: field.field_slug,
42
43
  field_type: field.field_type,
43
44
  field_role: field.field_role,
44
45
  field_placement: field.field_placement,
@@ -60,6 +61,7 @@ export async function seedTemplates(prismaClient) {
60
61
  fields: {
61
62
  create: template.fields.map((field) => ({
62
63
  field_name: field.field_name,
64
+ field_slug: field.field_slug,
63
65
  field_type: field.field_type,
64
66
  field_role: field.field_role,
65
67
  field_placement: field.field_placement,