@adaptware/eagles-db 0.5.48 → 0.5.49

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": "@adaptware/eagles-db",
3
- "version": "0.5.48",
3
+ "version": "0.5.49",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/prisma/.DS_Store CHANGED
Binary file
@@ -0,0 +1,2 @@
1
+ -- Migrate legacy terminal-positive status to SELECTED (SHORTLISTED enum value retained but unused).
2
+ UPDATE applications SET status = 'SELECTED' WHERE status = 'SHORTLISTED';
Binary file
@@ -1,10 +1,12 @@
1
- /// Immutable assignment history for Hiring Unit department/job changes.
1
+ /// Immutable assignment history for Hiring Unit department/user/job changes.
2
2
  model PurchasedHiringUnitAssignmentEvent {
3
3
  id String @id @default(uuid())
4
4
  purchased_hiring_unit_id String
5
5
  event_kind PurchasedHiringUnitAssignmentEventKind
6
6
  previous_department_id String?
7
7
  new_department_id String?
8
+ previous_assigned_user_id String?
9
+ new_assigned_user_id String?
8
10
  previous_job_description_id String?
9
11
  new_job_description_id String?
10
12
  effective_at DateTime @default(now())
@@ -34,6 +34,8 @@ enum PurchasedTopUpStatus {
34
34
  enum PurchasedHiringUnitAssignmentEventKind {
35
35
  DEPARTMENT_ASSIGNED
36
36
  DEPARTMENT_UNASSIGNED
37
+ USER_ASSIGNED
38
+ USER_UNASSIGNED
37
39
  JOB_LINKED
38
40
  JOB_UNLINKED
39
41
 
@@ -41,6 +41,8 @@ model PurchasedHiringUnit {
41
41
  status PurchasedHiringUnitStatus @default(AVAILABLE)
42
42
  /// Current department allocation (licensing allocation, not hiring manager).
43
43
  department_id String?
44
+ /// Optional person reservation. Units with this set are consumed before dept/org pools.
45
+ assigned_user_id String?
44
46
  /// Set once when department_id is first assigned; not cleared on reassignment.
45
47
  first_assigned_at DateTime?
46
48
  /// Optional unit expiry.
@@ -57,6 +59,7 @@ model PurchasedHiringUnit {
57
59
  organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
58
60
  purchased_license_package PurchasedLicensePackage @relation(fields: [purchased_license_package_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
59
61
  department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
62
+ assigned_user User? @relation("AssignedHiringUnits", fields: [assigned_user_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
60
63
  job_description JobDescription? @relation(fields: [job_description_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
61
64
  assignment_events PurchasedHiringUnitAssignmentEvent[]
62
65
  ledger_entries LicensingLedgerEntry[]
@@ -65,9 +68,11 @@ model PurchasedHiringUnit {
65
68
  @@index([organisation_id])
66
69
  @@index([purchased_license_package_id])
67
70
  @@index([department_id])
71
+ @@index([assigned_user_id])
68
72
  @@index([job_description_id])
69
73
  @@index([organisation_id, status])
70
74
  @@index([organisation_id, department_id])
75
+ @@index([organisation_id, assigned_user_id])
71
76
  @@index([organisation_id, job_description_id])
72
77
  @@map("purchased_hiring_units")
73
78
  @@schema("licensing")
@@ -0,0 +1,38 @@
1
+ -- Org policy for who may consume unused hiring units, plus optional user
2
+ -- reservation on each hiring unit. No row rewrite / backfill: existing units
3
+ -- stay department-only (assigned_user_id NULL). Scope default DEPARTMENT
4
+ -- matches current assign-to-department behaviour.
5
+
6
+ -- CreateEnum
7
+ CREATE TYPE "public"."HiringUnitAssignmentScope" AS ENUM ('USER', 'DEPARTMENT', 'ORGANISATION');
8
+
9
+ -- AlterTable
10
+ ALTER TABLE "Organisation"
11
+ ADD COLUMN "hiring_unit_assignment_scope" "public"."HiringUnitAssignmentScope" NOT NULL DEFAULT 'DEPARTMENT';
12
+
13
+ -- AlterEnum
14
+ -- Postgres 12+ permits ADD VALUE inside the migration transaction as long as
15
+ -- the new value is not also used there.
16
+ ALTER TYPE "licensing"."PurchasedHiringUnitAssignmentEventKind" ADD VALUE 'USER_ASSIGNED';
17
+ ALTER TYPE "licensing"."PurchasedHiringUnitAssignmentEventKind" ADD VALUE 'USER_UNASSIGNED';
18
+
19
+ -- AlterTable
20
+ ALTER TABLE "licensing"."purchased_hiring_units"
21
+ ADD COLUMN "assigned_user_id" TEXT;
22
+
23
+ ALTER TABLE "licensing"."purchased_hiring_unit_assignment_events"
24
+ ADD COLUMN "previous_assigned_user_id" TEXT,
25
+ ADD COLUMN "new_assigned_user_id" TEXT;
26
+
27
+ -- CreateIndex
28
+ CREATE INDEX "purchased_hiring_units_assigned_user_id_idx"
29
+ ON "licensing"."purchased_hiring_units"("assigned_user_id");
30
+
31
+ CREATE INDEX "purchased_hiring_units_organisation_id_assigned_user_id_idx"
32
+ ON "licensing"."purchased_hiring_units"("organisation_id", "assigned_user_id");
33
+
34
+ -- AddForeignKey
35
+ ALTER TABLE "licensing"."purchased_hiring_units"
36
+ ADD CONSTRAINT "purchased_hiring_units_assigned_user_id_fkey"
37
+ FOREIGN KEY ("assigned_user_id") REFERENCES "User"("id")
38
+ ON DELETE SET NULL ON UPDATE CASCADE;
@@ -8,6 +8,15 @@ enum OrganisationSize {
8
8
  @@schema("public")
9
9
  }
10
10
 
11
+ /// Who may consume unused hiring units. Changing this does not rewrite unit rows.
12
+ enum HiringUnitAssignmentScope {
13
+ USER
14
+ DEPARTMENT
15
+ ORGANISATION
16
+
17
+ @@schema("public")
18
+ }
19
+
11
20
  model Organisation {
12
21
  id String @id @default(uuid())
13
22
  name String @unique
@@ -50,6 +59,8 @@ model Organisation {
50
59
  timezone String @default("Asia/Kolkata")
51
60
  /// ISO 3166-1 alpha-2 (e.g. IN).
52
61
  country_code String @default("IN")
62
+ /// Who may consume unused hiring units. Does not rewrite unit rows when changed.
63
+ hiring_unit_assignment_scope HiringUnitAssignmentScope @default(DEPARTMENT)
53
64
  organisation_configs OrganisationConfig[]
54
65
  activity_events ActivityEvent[]
55
66
  usage_ledger_entries UsageLedgerEntry[]
@@ -100,7 +100,8 @@ model User {
100
100
  employee_number Int?
101
101
  employee_code String? @unique
102
102
 
103
- department_members DepartmentMember[] @relation("DepartmentMemberships")
103
+ department_members DepartmentMember[] @relation("DepartmentMemberships")
104
+ assigned_hiring_units PurchasedHiringUnit[] @relation("AssignedHiringUnits")
104
105
 
105
106
  @@index([role_id])
106
107
  @@index([permission_id])
Binary file