@adaptware/eagles-db 0.4.46 → 0.5.2

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.
Files changed (32) hide show
  1. package/client/edge.js +192 -6
  2. package/client/index-browser.js +187 -1
  3. package/client/index.d.ts +66407 -45772
  4. package/client/index.js +192 -6
  5. package/client/package.json +1 -1
  6. package/client/schema.prisma +338 -31
  7. package/client/wasm.js +192 -6
  8. package/package.json +1 -1
  9. package/prisma/schema/budget.prisma +4 -0
  10. package/prisma/schema/candidateProfile.prisma +9 -8
  11. package/prisma/schema/department.prisma +89 -0
  12. package/prisma/schema/hiringPlan.prisma +197 -0
  13. package/prisma/schema/jobDescription.prisma +10 -0
  14. package/prisma/schema/migrations/20260610100000_add_communication/migration.sql +131 -0
  15. package/prisma/schema/migrations/20260610170000_add_communication_application_scope/migration.sql +45 -0
  16. package/prisma/schema/migrations/20260718120000_add_hiring_plan/migration.sql +208 -0
  17. package/prisma/schema/migrations/20260718140000_hiring_plan_assumptions/migration.sql +2 -0
  18. package/prisma/schema/organisation.prisma +3 -1
  19. package/prisma/schema/user.prisma +2 -0
  20. package/client/libquery_engine-darwin.dylib.node +0 -0
  21. package/prisma/migrations/20260519120000_migrate_shortlisted_to_selected/migration.sql +0 -2
  22. package/prisma/schema/.DS_Store +0 -0
  23. package/prisma/schema/migrations/20260519120000_add_analytics_schema/migration.sql +0 -84
  24. package/prisma/schema/migrations/20260625120000_add_interviewer_analytics/migration.sql +0 -26
  25. package/prisma/schema/migrations/20260629120000_add_user_lifecycle_activity_events/migration.sql +0 -13
  26. package/prisma/schema/migrations/20260629140000_drop_organisation_org_code/migration.sql +0 -2
  27. package/prisma/schema/migrations/20260629160000_employee_codes_dual_interviewer_analytics/migration.sql +0 -87
  28. package/prisma/schema/migrations/20260630120000_add_application_sources/migration.sql +0 -38
  29. package/prisma/schema/migrations/20260701120000_add_source_effectiveness_analytics/migration.sql +0 -40
  30. package/prisma/schema/migrations/20260702120000_add_analytics_daily_tables/migration.sql +0 -232
  31. package/prisma/schema/migrations/20260716120000_evaluation_category_four_values/migration.sql +0 -204
  32. package/prisma/schema/migrations/20260716130000_application_withdrawn_analytics/migration.sql +0 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptware/eagles-db",
3
- "version": "0.4.46",
3
+ "version": "0.5.2",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,11 +34,15 @@ model Budget {
34
34
  jd_creation_type JDCreationType
35
35
  job_description_id String @unique
36
36
  job_description JobDescription @relation(fields: [job_description_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
37
+ /// Optional link to annual plan line (legacy Budget API; primary commit path is JobDescription).
38
+ hiring_plan_line_id String?
39
+ hiring_plan_line HiringPlanLine? @relation(fields: [hiring_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
37
40
  created_at DateTime @default(now())
38
41
  updated_at DateTime @updatedAt
39
42
  created_by String
40
43
  updated_by String
41
44
  is_active Boolean @default(true)
42
45
 
46
+ @@index([hiring_plan_line_id])
43
47
  @@schema("public")
44
48
  }
@@ -15,14 +15,15 @@ model CandidateProfile {
15
15
 
16
16
  resume Resume? @relation(fields: [resume_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
17
17
 
18
- work_experience Json?
19
- education Json?
20
- notice_period String?
21
- gender String?
22
- ethnicity String?
23
- veteran_status String?
24
- disability_status String?
25
- is_active Boolean @default(true)
18
+ work_experience Json?
19
+ education Json?
20
+ notice_period String?
21
+ gender String?
22
+ ethnicity String?
23
+ veteran_status String?
24
+ disability_status String?
25
+ is_active Boolean @default(true)
26
+ planned_candidates PlannedCandidate[]
26
27
 
27
28
  @@schema("public")
28
29
  }
@@ -0,0 +1,89 @@
1
+ /// Section-level status for a department's slice of the hiring plan.
2
+ /// DRAFT — department head is editing
3
+ /// SUBMITTED — head submitted; awaiting CHRO
4
+ /// APPROVED — CHRO locked; line writes rejected until reopened to DRAFT
5
+ enum HiringPlanSectionStatus {
6
+ DRAFT
7
+ SUBMITTED
8
+ APPROVED
9
+
10
+ @@schema("public")
11
+ }
12
+
13
+ /// First-class org unit that owns a slice of the annual hiring plan.
14
+ /// Replaces the free-text `business_unit` string on HiringPlanLine / Employee.
15
+ /// Headship lives on DepartmentMember.is_head (at most one per dept, enforced in service).
16
+ model Department {
17
+ id String @id @default(uuid())
18
+ organisation_id String
19
+ name String
20
+ code String?
21
+ /// Global display order across departments within the org (drag-reorder in plan grid).
22
+ sort_order Int @default(0)
23
+ created_at DateTime @default(now())
24
+ updated_at DateTime @updatedAt
25
+ created_by String
26
+ updated_by String
27
+ is_active Boolean @default(true)
28
+
29
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
30
+ members DepartmentMember[]
31
+ hiring_plan_lines HiringPlanLine[]
32
+ employees Employee[]
33
+ job_descriptions JobDescription[]
34
+ sections HiringPlanSection[]
35
+
36
+ @@unique([organisation_id, name])
37
+ @@index([organisation_id])
38
+ @@schema("public")
39
+ }
40
+
41
+ /// Many-to-many membership: a user can belong to multiple departments.
42
+ /// is_head marks the department head for that membership row. The same user can
43
+ /// be head of multiple departments (multiple rows with is_head=true). At most
44
+ /// one is_head=true per department is enforced in DepartmentService.
45
+ model DepartmentMember {
46
+ id String @id @default(uuid())
47
+ department_id String
48
+ user_id String
49
+ is_head Boolean @default(false)
50
+ created_at DateTime @default(now())
51
+ updated_at DateTime @updatedAt
52
+ created_by String
53
+ updated_by String
54
+ is_active Boolean @default(true)
55
+
56
+ department Department @relation(fields: [department_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
57
+ user User @relation("DepartmentMemberships", fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
58
+
59
+ @@unique([department_id, user_id])
60
+ @@index([user_id])
61
+ @@index([department_id, is_head])
62
+ @@schema("public")
63
+ }
64
+
65
+ /// Per-department status for a specific hiring plan (submit → approve/lock).
66
+ model HiringPlanSection {
67
+ id String @id @default(uuid())
68
+ hiring_plan_id String
69
+ department_id String
70
+ status HiringPlanSectionStatus @default(DRAFT)
71
+ submitted_by String?
72
+ submitted_at DateTime?
73
+ approved_by String?
74
+ approved_at DateTime?
75
+ created_at DateTime @default(now())
76
+ updated_at DateTime @updatedAt
77
+ created_by String
78
+ updated_by String
79
+ is_active Boolean @default(true)
80
+
81
+ hiring_plan HiringPlan @relation(fields: [hiring_plan_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
82
+ department Department @relation(fields: [department_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
83
+
84
+ @@unique([hiring_plan_id, department_id])
85
+ @@index([hiring_plan_id])
86
+ @@index([department_id])
87
+ @@index([status])
88
+ @@schema("public")
89
+ }
@@ -0,0 +1,197 @@
1
+ enum HiringPlanStatus {
2
+ DRAFT
3
+ ACTIVE
4
+ CLOSED
5
+
6
+ @@schema("public")
7
+ }
8
+
9
+ enum PeriodType {
10
+ ANNUAL
11
+
12
+ @@schema("public")
13
+ }
14
+
15
+ enum EmployeeStatus {
16
+ ACTIVE
17
+ ATTRITION_EXPECTED
18
+ DEPARTED
19
+
20
+ @@schema("public")
21
+ }
22
+
23
+ enum AttritionRisk {
24
+ LOW
25
+ MEDIUM
26
+ HIGH
27
+
28
+ @@schema("public")
29
+ }
30
+
31
+ enum ReviewRating {
32
+ OUTSTANDING
33
+ EXCEEDS_EXPECTATIONS
34
+ MEETS_EXPECTATIONS
35
+ NEEDS_IMPROVEMENT
36
+ UNSATISFACTORY
37
+
38
+ @@schema("public")
39
+ }
40
+
41
+ enum PlannedCandidateStatus {
42
+ IDENTIFIED
43
+ IN_PIPELINE
44
+ OFFER
45
+ SELECTED
46
+ DECLINED
47
+
48
+ @@schema("public")
49
+ }
50
+
51
+ /// Org-level annual hiring plan (CHRO budgeting).
52
+ model HiringPlan {
53
+ id String @id @default(uuid())
54
+ organisation_id String
55
+ fiscal_year Int
56
+ period_type PeriodType @default(ANNUAL)
57
+ currency String @default("INR")
58
+ status HiringPlanStatus @default(DRAFT)
59
+ total_headcount_budget Int?
60
+ total_cost_budget Decimal? @db.Decimal(18, 2)
61
+ /// Workbook assumptions (multipliers, inflation, fiscal start month, etc.).
62
+ assumptions Json?
63
+ notes String?
64
+ created_at DateTime @default(now())
65
+ updated_at DateTime @updatedAt
66
+ created_by String
67
+ updated_by String
68
+ is_active Boolean @default(true)
69
+
70
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
71
+ lines HiringPlanLine[]
72
+ sections HiringPlanSection[]
73
+
74
+ @@unique([organisation_id, fiscal_year])
75
+ @@index([organisation_id])
76
+ @@index([status])
77
+ @@schema("public")
78
+ }
79
+
80
+ /// One allocation row: dimensions + planned headcount + monthly phasing inputs.
81
+ model HiringPlanLine {
82
+ id String @id @default(uuid())
83
+ hiring_plan_id String
84
+ /// Owning department (grouping + section ownership). Legacy `business_unit` is
85
+ /// kept for back-compat and populated from Department.name for a while.
86
+ department_id String?
87
+ business_unit String?
88
+ level String?
89
+ location String?
90
+ role String?
91
+ planned_headcount Int @default(1)
92
+ /// Fully-loaded annual run-rate cost per hire (not in-year cost).
93
+ cost_per_hire Decimal @db.Decimal(18, 2)
94
+ /// Fiscal month 1–12 when hires start (used when hire_schedule is null).
95
+ start_month Int @default(1)
96
+ /// Optional staggered starts: { "1": 2, "4": 2 } (fiscal-month → count).
97
+ hire_schedule Json?
98
+ /// Display order within a business unit (lower first).
99
+ sort_order Int @default(0)
100
+ /// Reference/template JD for this role (definition).
101
+ job_description_id String?
102
+ created_at DateTime @default(now())
103
+ updated_at DateTime @updatedAt
104
+ created_by String
105
+ updated_by String
106
+ is_active Boolean @default(true)
107
+
108
+ hiring_plan HiringPlan @relation(fields: [hiring_plan_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
109
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
110
+ job_description JobDescription? @relation("PlanLineTemplateJd", fields: [job_description_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
111
+ requisitions JobDescription[] @relation("PlanLineRequisitions")
112
+ budgets Budget[]
113
+ planned_candidates PlannedCandidate[]
114
+ backfill_from_employees Employee[] @relation("EmployeeBackfillLine")
115
+
116
+ @@index([hiring_plan_id])
117
+ @@index([department_id])
118
+ @@index([job_description_id])
119
+ @@index([business_unit, level, location, role])
120
+ @@schema("public")
121
+ }
122
+
123
+ /// Existing workforce roster (manual / CSV). Baseline for net-new vs backfill.
124
+ model Employee {
125
+ id String @id @default(uuid())
126
+ organisation_id String
127
+ /// Owning department (Department.name mirrors legacy business_unit for back-compat).
128
+ department_id String?
129
+ employee_code String?
130
+ name String?
131
+ email String?
132
+ gender String?
133
+ business_unit String?
134
+ level String?
135
+ location String?
136
+ role String?
137
+ employment_type JobType?
138
+ starting_designation String?
139
+ current_designation String?
140
+ start_date DateTime?
141
+ starting_salary Decimal? @db.Decimal(18, 2)
142
+ /// Comp immediately before the latest raise (or prior cycle). Optional.
143
+ previous_salary Decimal? @db.Decimal(18, 2)
144
+ current_comp Decimal @db.Decimal(18, 2)
145
+ currency String @default("INR")
146
+ last_increment_date DateTime?
147
+ last_increment_amount Decimal? @db.Decimal(18, 2)
148
+ last_increment_pct Decimal? @db.Decimal(8, 4)
149
+ last_review_date DateTime?
150
+ last_review_rating ReviewRating?
151
+ last_feedback_date DateTime?
152
+ last_feedback_summary String?
153
+ status EmployeeStatus @default(ACTIVE)
154
+ attrition_risk AttritionRisk?
155
+ expected_exit_date DateTime?
156
+ backfill_plan_line_id String?
157
+ created_at DateTime @default(now())
158
+ updated_at DateTime @updatedAt
159
+ created_by String
160
+ updated_by String
161
+ is_active Boolean @default(true)
162
+
163
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
164
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
165
+ backfill_plan_line HiringPlanLine? @relation("EmployeeBackfillLine", fields: [backfill_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
166
+
167
+ @@unique([organisation_id, employee_code])
168
+ @@index([organisation_id])
169
+ @@index([department_id])
170
+ @@index([status])
171
+ @@index([business_unit, level, location, role])
172
+ @@index([backfill_plan_line_id])
173
+ @@schema("public")
174
+ }
175
+
176
+ /// Tentative candidate attached to a plan line (ATS CandidateProfile or free-text).
177
+ model PlannedCandidate {
178
+ id String @id @default(uuid())
179
+ hiring_plan_line_id String
180
+ candidate_profile_id String?
181
+ name String?
182
+ status PlannedCandidateStatus @default(IDENTIFIED)
183
+ note String?
184
+ created_at DateTime @default(now())
185
+ updated_at DateTime @updatedAt
186
+ created_by String
187
+ updated_by String
188
+ is_active Boolean @default(true)
189
+
190
+ hiring_plan_line HiringPlanLine @relation(fields: [hiring_plan_line_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
191
+ candidate_profile CandidateProfile? @relation(fields: [candidate_profile_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
192
+
193
+ @@index([hiring_plan_line_id])
194
+ @@index([candidate_profile_id])
195
+ @@index([status])
196
+ @@schema("public")
197
+ }
@@ -11,6 +11,8 @@ enum JobDescriptionStatus {
11
11
  model JobDescription {
12
12
  id String @id @default(uuid())
13
13
  organisation_id String
14
+ /// Owning department (visibility scope for DepartmentHead; optional).
15
+ department_id String?
14
16
  hiring_manager_id String?
15
17
  status JobDescriptionStatus @default(DRAFT)
16
18
  screeningQuestions String[]
@@ -43,6 +45,7 @@ model JobDescription {
43
45
  job_profile_id String?
44
46
  job_profile JobProfile? @relation(fields: [job_profile_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
45
47
  organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
48
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
46
49
  source_document Document? @relation("SourceDocument", fields: [source_document_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
47
50
  applications Application[]
48
51
  interviews Interview[]
@@ -62,9 +65,16 @@ model JobDescription {
62
65
  job_application_template JobApplicationTemplate?
63
66
  conversations Conversation[]
64
67
  communication_messages CommunicationMessage[]
68
+ /// Plan line this opening is committed against (requisition → plan).
69
+ hiring_plan_line_id String?
70
+ hiring_plan_line HiringPlanLine? @relation("PlanLineRequisitions", fields: [hiring_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
71
+ /// Plan lines that use this JD as the role template/reference.
72
+ referenced_by_plan_lines HiringPlanLine[] @relation("PlanLineTemplateJd")
65
73
 
66
74
  @@index([organisation_id])
67
75
  @@index([hiring_manager_id])
68
76
  @@index([job_profile_id])
77
+ @@index([hiring_plan_line_id])
78
+ @@index([department_id])
69
79
  @@schema("public")
70
80
  }
@@ -0,0 +1,131 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "CommChannel" AS ENUM ('WHATSAPP', 'EMAIL', 'SMS', 'CALL');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "CommProvider" AS ENUM ('META_WHATSAPP', 'TWILIO', 'GUPSHUP', 'MTALKZ', 'THREE_SIXTY_DIALOG', 'GMAIL', 'OUTLOOK', 'GENERIC_SMTP', 'GENERIC');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "CommDirection" AS ENUM ('INBOUND', 'OUTBOUND');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "CommMessageStatus" AS ENUM ('QUEUED', 'SENT', 'DELIVERED', 'READ', 'FAILED', 'RECEIVED');
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "ChannelProviderConfig" (
15
+ "id" TEXT NOT NULL,
16
+ "organisation_id" TEXT NOT NULL,
17
+ "channel" "CommChannel" NOT NULL,
18
+ "provider" "CommProvider" NOT NULL,
19
+ "credentials" TEXT,
20
+ "metadata" JSONB NOT NULL DEFAULT '{}',
21
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
22
+ "is_default" BOOLEAN NOT NULL DEFAULT true,
23
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
24
+ "updated_at" TIMESTAMP(3) NOT NULL,
25
+ "created_by" TEXT NOT NULL,
26
+ "updated_by" TEXT NOT NULL,
27
+
28
+ CONSTRAINT "ChannelProviderConfig_pkey" PRIMARY KEY ("id")
29
+ );
30
+
31
+ -- CreateTable
32
+ CREATE TABLE "Conversation" (
33
+ "id" TEXT NOT NULL,
34
+ "organisation_id" TEXT NOT NULL,
35
+ "channel" "CommChannel" NOT NULL,
36
+ "provider" "CommProvider" NOT NULL,
37
+ "channel_provider_id" TEXT,
38
+ "external_id" TEXT NOT NULL,
39
+ "contact_user_id" TEXT,
40
+ "provider_thread_id" TEXT,
41
+ "subject" TEXT,
42
+ "status" TEXT NOT NULL DEFAULT 'open',
43
+ "unread_count" INTEGER NOT NULL DEFAULT 0,
44
+ "last_message_at" TIMESTAMP(3),
45
+ "metadata" JSONB NOT NULL DEFAULT '{}',
46
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
47
+ "updated_at" TIMESTAMP(3) NOT NULL,
48
+ "created_by" TEXT NOT NULL,
49
+ "updated_by" TEXT NOT NULL,
50
+
51
+ CONSTRAINT "Conversation_pkey" PRIMARY KEY ("id")
52
+ );
53
+
54
+ -- CreateTable
55
+ CREATE TABLE "CommunicationMessage" (
56
+ "id" TEXT NOT NULL,
57
+ "conversation_id" TEXT NOT NULL,
58
+ "organisation_id" TEXT NOT NULL,
59
+ "channel" "CommChannel" NOT NULL,
60
+ "provider" "CommProvider" NOT NULL,
61
+ "channel_provider_id" TEXT,
62
+ "direction" "CommDirection" NOT NULL,
63
+ "status" "CommMessageStatus" NOT NULL,
64
+ "body" TEXT,
65
+ "from_identifier" TEXT NOT NULL,
66
+ "to_identifier" TEXT NOT NULL,
67
+ "sender_user_id" TEXT,
68
+ "provider_message_id" TEXT,
69
+ "template_name" TEXT,
70
+ "attachments" JSONB NOT NULL DEFAULT '[]',
71
+ "metadata" JSONB NOT NULL DEFAULT '{}',
72
+ "error" TEXT,
73
+ "sent_at" TIMESTAMP(3),
74
+ "delivered_at" TIMESTAMP(3),
75
+ "read_at" TIMESTAMP(3),
76
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
77
+ "updated_at" TIMESTAMP(3) NOT NULL,
78
+
79
+ CONSTRAINT "CommunicationMessage_pkey" PRIMARY KEY ("id")
80
+ );
81
+
82
+ -- CreateIndex
83
+ CREATE UNIQUE INDEX "ChannelProviderConfig_organisation_id_channel_provider_key" ON "ChannelProviderConfig"("organisation_id", "channel", "provider");
84
+
85
+ -- CreateIndex
86
+ CREATE INDEX "ChannelProviderConfig_organisation_id_channel_idx" ON "ChannelProviderConfig"("organisation_id", "channel");
87
+
88
+ -- CreateIndex
89
+ CREATE INDEX "ChannelProviderConfig_organisation_id_channel_is_active_idx" ON "ChannelProviderConfig"("organisation_id", "channel", "is_active");
90
+
91
+ -- CreateIndex
92
+ CREATE UNIQUE INDEX "Conversation_organisation_id_channel_provider_external_id_key" ON "Conversation"("organisation_id", "channel", "provider", "external_id");
93
+
94
+ -- CreateIndex
95
+ CREATE INDEX "Conversation_organisation_id_channel_idx" ON "Conversation"("organisation_id", "channel");
96
+
97
+ -- CreateIndex
98
+ CREATE INDEX "Conversation_organisation_id_last_message_at_idx" ON "Conversation"("organisation_id", "last_message_at");
99
+
100
+ -- CreateIndex
101
+ CREATE INDEX "Conversation_external_id_idx" ON "Conversation"("external_id");
102
+
103
+ -- CreateIndex
104
+ CREATE UNIQUE INDEX "CommunicationMessage_provider_provider_message_id_key" ON "CommunicationMessage"("provider", "provider_message_id");
105
+
106
+ -- CreateIndex
107
+ CREATE INDEX "CommunicationMessage_conversation_id_created_at_idx" ON "CommunicationMessage"("conversation_id", "created_at");
108
+
109
+ -- CreateIndex
110
+ CREATE INDEX "CommunicationMessage_organisation_id_channel_created_at_idx" ON "CommunicationMessage"("organisation_id", "channel", "created_at");
111
+
112
+ -- CreateIndex
113
+ CREATE INDEX "CommunicationMessage_organisation_id_status_idx" ON "CommunicationMessage"("organisation_id", "status");
114
+
115
+ -- AddForeignKey
116
+ ALTER TABLE "ChannelProviderConfig" ADD CONSTRAINT "ChannelProviderConfig_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
117
+
118
+ -- AddForeignKey
119
+ ALTER TABLE "Conversation" ADD CONSTRAINT "Conversation_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
120
+
121
+ -- AddForeignKey
122
+ ALTER TABLE "Conversation" ADD CONSTRAINT "Conversation_channel_provider_id_fkey" FOREIGN KEY ("channel_provider_id") REFERENCES "ChannelProviderConfig"("id") ON DELETE SET NULL ON UPDATE CASCADE;
123
+
124
+ -- AddForeignKey
125
+ ALTER TABLE "CommunicationMessage" ADD CONSTRAINT "CommunicationMessage_conversation_id_fkey" FOREIGN KEY ("conversation_id") REFERENCES "Conversation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
126
+
127
+ -- AddForeignKey
128
+ ALTER TABLE "CommunicationMessage" ADD CONSTRAINT "CommunicationMessage_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
129
+
130
+ -- AddForeignKey
131
+ ALTER TABLE "CommunicationMessage" ADD CONSTRAINT "CommunicationMessage_channel_provider_id_fkey" FOREIGN KEY ("channel_provider_id") REFERENCES "ChannelProviderConfig"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,45 @@
1
+ -- AlterTable: Conversation
2
+ ALTER TABLE "Conversation"
3
+ ADD COLUMN "application_id" TEXT,
4
+ ADD COLUMN "job_description_id" TEXT;
5
+
6
+ -- AlterTable: CommunicationMessage
7
+ ALTER TABLE "CommunicationMessage"
8
+ ADD COLUMN "application_id" TEXT,
9
+ ADD COLUMN "job_description_id" TEXT;
10
+
11
+ -- CreateIndex
12
+ CREATE INDEX "Conversation_organisation_id_application_id_idx" ON "Conversation"("organisation_id", "application_id");
13
+
14
+ -- CreateIndex
15
+ CREATE INDEX "Conversation_organisation_id_job_description_id_idx" ON "Conversation"("organisation_id", "job_description_id");
16
+
17
+ -- CreateIndex
18
+ CREATE INDEX "CommunicationMessage_organisation_id_application_id_idx" ON "CommunicationMessage"("organisation_id", "application_id");
19
+
20
+ -- CreateIndex
21
+ CREATE INDEX "CommunicationMessage_organisation_id_job_description_id_idx" ON "CommunicationMessage"("organisation_id", "job_description_id");
22
+
23
+ -- AddForeignKey
24
+ ALTER TABLE "Conversation"
25
+ ADD CONSTRAINT "Conversation_application_id_fkey"
26
+ FOREIGN KEY ("application_id") REFERENCES "Application"("id")
27
+ ON DELETE SET NULL ON UPDATE CASCADE;
28
+
29
+ -- AddForeignKey
30
+ ALTER TABLE "Conversation"
31
+ ADD CONSTRAINT "Conversation_job_description_id_fkey"
32
+ FOREIGN KEY ("job_description_id") REFERENCES "JobDescription"("id")
33
+ ON DELETE SET NULL ON UPDATE CASCADE;
34
+
35
+ -- AddForeignKey
36
+ ALTER TABLE "CommunicationMessage"
37
+ ADD CONSTRAINT "CommunicationMessage_application_id_fkey"
38
+ FOREIGN KEY ("application_id") REFERENCES "Application"("id")
39
+ ON DELETE SET NULL ON UPDATE CASCADE;
40
+
41
+ -- AddForeignKey
42
+ ALTER TABLE "CommunicationMessage"
43
+ ADD CONSTRAINT "CommunicationMessage_job_description_id_fkey"
44
+ FOREIGN KEY ("job_description_id") REFERENCES "JobDescription"("id")
45
+ ON DELETE SET NULL ON UPDATE CASCADE;