procbay-schema 1.0.63 → 1.0.65

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.63",
3
+ "version": "1.0.65",
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",
@@ -1,6 +1,7 @@
1
1
  [
2
2
  {
3
3
  "department_name": "Finance Management",
4
+ "department_code": "FIN-01",
4
5
  "department_slug": "finance-management",
5
6
  "description": "Manages budgeting, accounting, and financial reporting to ensure economic stability.",
6
7
  "is_active": true
@@ -0,0 +1,5 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "EnvironmentEnum" AS ENUM ('PRODUCTION', 'SANDBOX');
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "users" ADD COLUMN "user_environment" "EnvironmentEnum" NOT NULL DEFAULT 'PRODUCTION';
@@ -39,6 +39,11 @@ enum StatusEnum {
39
39
  Suspended
40
40
  }
41
41
 
42
+ enum EnvironmentEnum {
43
+ PRODUCTION
44
+ SANDBOX
45
+ }
46
+
42
47
  model User {
43
48
  id Int @id @default(autoincrement())
44
49
  uuid String? @unique @default(uuid())
@@ -68,6 +73,7 @@ model User {
68
73
  is_deleted Boolean @default(false)
69
74
  deleted_at DateTime? @db.Timestamptz(6)
70
75
  deleted_by Int?
76
+ user_environment EnvironmentEnum @default(PRODUCTION)
71
77
  user_roles UserRole[]
72
78
  user_department UserDepartment[]
73
79
  approval_hierarchy ApprovalHierarchy[]
@@ -1,11 +1,6 @@
1
1
  import { PrismaClient } from "../../src/prisma/index.js";
2
2
  import { loadCoreData } from "./utils/json-loader.js";
3
- import {
4
- createProgressTracker,
5
- logSeederStart,
6
- logSeederComplete,
7
- logEntityError,
8
- } from "./utils/progress-tracker.js";
3
+ import { seedCoreEntity } from "./utils/core-seeder.js";
9
4
 
10
5
  export async function seedSerialNumberConfigurations(
11
6
  prismaClient,
@@ -14,51 +9,35 @@ export async function seedSerialNumberConfigurations(
14
9
  // Use the passed client or create new one only if needed (for standalone testing)
15
10
  const prisma = prismaClient || new PrismaClient();
16
11
 
17
- // Note: seederManager is available but not currently used due to simple loop-based processing
18
- // Future optimization: Consider using seedCoreEntity for batch processing
19
-
20
- logSeederStart("serial number configurations");
21
-
22
- // Load serial-number configurations from JSON
23
- const serialNumberData = loadCoreData("serial-number-config");
24
-
25
- // Create progress tracker
26
- const tracker = createProgressTracker(
27
- serialNumberData.length,
28
- "serial number configurations"
29
- );
30
-
31
- for (const serialConfig of serialNumberData) {
32
- try {
33
- await prisma.serialNumberConfiguration.upsert({
34
- where: {
35
- module: serialConfig.module,
36
- },
37
- update: {
38
- alias: serialConfig.alias,
12
+ try {
13
+ // Load serial-number configurations from JSON
14
+ const serialNumberData = loadCoreData("serial-number-config");
15
+
16
+ // Process serial number configurations with optimized core seeder
17
+ const result = await seedCoreEntity(
18
+ prisma,
19
+ serialNumberData,
20
+ "serial number configurations",
21
+ {
22
+ model: "serialNumberConfiguration",
23
+ whereField: "module",
24
+ updateFields: ["alias"], // Only update alias, preserve current_number
25
+ createFields: ["module", "alias", "initial_number", "current_number"],
26
+ },
27
+ {
28
+ performanceConfig: seederManager?.performanceConfig || {
29
+ profile: "stability",
39
30
  },
40
- create: {
41
- module: serialConfig.module,
42
- alias: serialConfig.alias,
43
- initial_number: serialConfig.initial_number,
44
- current_number: serialConfig.current_number,
45
- },
46
- });
47
- } catch (error) {
48
- // Log error but don't interrupt progress bar
49
- logEntityError(
50
- "serial number configuration",
51
- serialConfig.module,
52
- error.message
53
- );
31
+ enableRetries: true,
32
+ logProgress: true,
33
+ }
34
+ );
35
+
36
+ return result;
37
+ } finally {
38
+ // Only disconnect if we created our own client
39
+ if (!prismaClient) {
40
+ await prisma.$disconnect();
54
41
  }
55
- tracker.update();
56
- }
57
-
58
- logSeederComplete("Serial number configurations");
59
-
60
- // Only disconnect if we created our own client
61
- if (!prismaClient) {
62
- await prisma.$disconnect();
63
42
  }
64
43
  }