@adaptware/eagles-db 0.5.34 → 0.5.36
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/client/edge.js +15 -232
- package/client/index-browser.js +8 -226
- package/client/index.d.ts +87500 -107633
- package/client/index.js +15 -232
- package/client/package.json +1 -1
- package/client/schema.prisma +147 -490
- package/client/wasm.js +15 -232
- package/package.json +1 -1
- package/prisma/.DS_Store +0 -0
- package/prisma/schema/.DS_Store +0 -0
- package/prisma/schema/applications.prisma +34 -29
- package/prisma/schema/department.prisma +2 -3
- package/prisma/schema/document.prisma +1 -0
- package/prisma/schema/jobDescription.prisma +0 -1
- package/prisma/schema/migrations/.DS_Store +0 -0
- package/prisma/schema/migrations/20260826160000_add_application_fit_check_report_document/.DS_Store +0 -0
- package/prisma/schema/migrations/20260826160000_add_application_fit_check_report_document/migration.sql +13 -0
- package/prisma/schema/organisation.prisma +0 -6
- package/prisma/schema/schema.prisma +1 -1
- package/client/libquery_engine-darwin.dylib.node +0 -0
- package/prisma/migrations/20260519120000_migrate_shortlisted_to_selected/migration.sql +0 -2
- package/prisma/schema/licensing/aiCostLedger.prisma +0 -34
- package/prisma/schema/licensing/assignmentHistory.prisma +0 -19
- package/prisma/schema/licensing/licensePackageCatalog.prisma +0 -62
- package/prisma/schema/licensing/licensingEnums.prisma +0 -80
- package/prisma/schema/licensing/licensingLedger.prisma +0 -32
- package/prisma/schema/licensing/purchasedLicense.prisma +0 -74
- package/prisma/schema/licensing/purchasedTopUp.prisma +0 -39
- package/prisma/schema/migrations/20260519120000_add_analytics_schema/migration.sql +0 -84
- package/prisma/schema/migrations/20260625120000_add_interviewer_analytics/migration.sql +0 -26
- package/prisma/schema/migrations/20260629120000_add_user_lifecycle_activity_events/migration.sql +0 -13
- package/prisma/schema/migrations/20260629140000_drop_organisation_org_code/migration.sql +0 -2
- package/prisma/schema/migrations/20260629160000_employee_codes_dual_interviewer_analytics/migration.sql +0 -87
- package/prisma/schema/migrations/20260630120000_add_application_sources/migration.sql +0 -38
- package/prisma/schema/migrations/20260701120000_add_source_effectiveness_analytics/migration.sql +0 -40
- package/prisma/schema/migrations/20260702120000_add_analytics_daily_tables/migration.sql +0 -232
- package/prisma/schema/migrations/20260716120000_evaluation_category_four_values/migration.sql +0 -204
- package/prisma/schema/migrations/20260716130000_application_withdrawn_analytics/migration.sql +0 -31
- package/prisma/schema/migrations/20260804120000_contact_us_optional_website_subject/migration.sql +0 -3
- package/prisma/schema/migrations/20260810120000_add_licensing_schema/migration.sql +0 -237
- package/prisma/schema/migrations/20260814153000_add_licensing_ledger/migration.sql +0 -236
- package/prisma/schema/migrations/20260828120000_license_package_orgs_cost_price_ai_cost_ledger/migration.sql +0 -74
- package/prisma/schema/migrations/20260831120000_ai_cost_ledger_purchase_reason/migration.sql +0 -2
- package/prisma/schema/migrations/20260831140000_ai_cost_ledger_nullable_hiring_unit/migration.sql +0 -3
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
-- CreateSchema
|
|
2
|
-
CREATE SCHEMA IF NOT EXISTS "licensing";
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "licensing"."LicensePackageStatus" AS ENUM ('DRAFT', 'ACTIVE', 'ARCHIVED');
|
|
6
|
-
|
|
7
|
-
-- CreateEnum
|
|
8
|
-
CREATE TYPE "licensing"."PurchasedLicensePackageStatus" AS ENUM ('ACTIVE', 'EXPIRED', 'CANCELLED');
|
|
9
|
-
|
|
10
|
-
-- CreateEnum
|
|
11
|
-
CREATE TYPE "licensing"."PurchasedHiringUnitStatus" AS ENUM ('AVAILABLE', 'ASSIGNED', 'ACTIVE', 'EXHAUSTED', 'DEACTIVATED');
|
|
12
|
-
|
|
13
|
-
-- CreateEnum
|
|
14
|
-
CREATE TYPE "licensing"."PurchasedTopUpStatus" AS ENUM ('ACTIVE', 'DEPLETED', 'CANCELLED');
|
|
15
|
-
|
|
16
|
-
-- CreateEnum
|
|
17
|
-
CREATE TYPE "licensing"."PurchasedHiringUnitAssignmentEventKind" AS ENUM ('DEPARTMENT_ASSIGNED', 'DEPARTMENT_UNASSIGNED', 'JOB_LINKED', 'JOB_UNLINKED');
|
|
18
|
-
|
|
19
|
-
-- CreateTable
|
|
20
|
-
CREATE TABLE "licensing"."license_packages" (
|
|
21
|
-
"id" TEXT NOT NULL,
|
|
22
|
-
"code" TEXT NOT NULL,
|
|
23
|
-
"version" INTEGER NOT NULL,
|
|
24
|
-
"name" TEXT NOT NULL,
|
|
25
|
-
"description" TEXT,
|
|
26
|
-
"price" DECIMAL(18,2) NOT NULL,
|
|
27
|
-
"currency" TEXT NOT NULL DEFAULT 'INR',
|
|
28
|
-
"status" "licensing"."LicensePackageStatus" NOT NULL DEFAULT 'DRAFT',
|
|
29
|
-
"units_per_purchase" INTEGER NOT NULL,
|
|
30
|
-
"interview_ai_assisted_hours" DECIMAL(20,4),
|
|
31
|
-
"interview_full_ai_hours" DECIMAL(20,4),
|
|
32
|
-
"interview_non_ai_hours" DECIMAL(20,4),
|
|
33
|
-
"assignment_count" DECIMAL(20,4),
|
|
34
|
-
"test_count" DECIMAL(20,4),
|
|
35
|
-
"resume_count" DECIMAL(20,4),
|
|
36
|
-
"credits" DECIMAL(20,4),
|
|
37
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
39
|
-
"created_by" TEXT NOT NULL,
|
|
40
|
-
"updated_by" TEXT NOT NULL,
|
|
41
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
42
|
-
|
|
43
|
-
CONSTRAINT "license_packages_pkey" PRIMARY KEY ("id")
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
-- CreateTable
|
|
47
|
-
CREATE TABLE "licensing"."purchased_license_packages" (
|
|
48
|
-
"id" TEXT NOT NULL,
|
|
49
|
-
"organisation_id" TEXT NOT NULL,
|
|
50
|
-
"license_package_id" TEXT NOT NULL,
|
|
51
|
-
"package_code" TEXT NOT NULL,
|
|
52
|
-
"package_version" INTEGER NOT NULL,
|
|
53
|
-
"package_name" TEXT NOT NULL,
|
|
54
|
-
"price" DECIMAL(18,2) NOT NULL,
|
|
55
|
-
"currency" TEXT NOT NULL DEFAULT 'INR',
|
|
56
|
-
"units_per_purchase" INTEGER NOT NULL,
|
|
57
|
-
"package_quantity" INTEGER NOT NULL DEFAULT 1,
|
|
58
|
-
"purchased_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
59
|
-
"status" "licensing"."PurchasedLicensePackageStatus" NOT NULL DEFAULT 'ACTIVE',
|
|
60
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
61
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
62
|
-
"created_by" TEXT NOT NULL,
|
|
63
|
-
"updated_by" TEXT NOT NULL,
|
|
64
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
65
|
-
|
|
66
|
-
CONSTRAINT "purchased_license_packages_pkey" PRIMARY KEY ("id")
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
-- CreateTable
|
|
70
|
-
CREATE TABLE "licensing"."purchased_hiring_units" (
|
|
71
|
-
"id" TEXT NOT NULL,
|
|
72
|
-
"organisation_id" TEXT NOT NULL,
|
|
73
|
-
"purchased_license_package_id" TEXT NOT NULL,
|
|
74
|
-
"unit_sequence" INTEGER NOT NULL,
|
|
75
|
-
"status" "licensing"."PurchasedHiringUnitStatus" NOT NULL DEFAULT 'AVAILABLE',
|
|
76
|
-
"department_id" TEXT,
|
|
77
|
-
"first_assigned_at" TIMESTAMP(3),
|
|
78
|
-
"expiry_at" TIMESTAMP(3),
|
|
79
|
-
"job_description_id" TEXT,
|
|
80
|
-
"interview_ai_assisted_hours" DECIMAL(20,4),
|
|
81
|
-
"interview_full_ai_hours" DECIMAL(20,4),
|
|
82
|
-
"interview_non_ai_hours" DECIMAL(20,4),
|
|
83
|
-
"assignment_count" DECIMAL(20,4),
|
|
84
|
-
"test_count" DECIMAL(20,4),
|
|
85
|
-
"resume_count" DECIMAL(20,4),
|
|
86
|
-
"credits" DECIMAL(20,4),
|
|
87
|
-
"interview_ai_assisted_hours_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
88
|
-
"interview_full_ai_hours_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
89
|
-
"interview_non_ai_hours_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
90
|
-
"assignment_count_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
91
|
-
"test_count_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
92
|
-
"resume_count_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
93
|
-
"credits_consumed" DECIMAL(20,4) DEFAULT 0,
|
|
94
|
-
"interview_ai_assisted_hours_topup" DECIMAL(20,4) DEFAULT 0,
|
|
95
|
-
"interview_full_ai_hours_topup" DECIMAL(20,4) DEFAULT 0,
|
|
96
|
-
"interview_non_ai_hours_topup" DECIMAL(20,4) DEFAULT 0,
|
|
97
|
-
"assignment_count_topup" DECIMAL(20,4) DEFAULT 0,
|
|
98
|
-
"test_count_topup" DECIMAL(20,4) DEFAULT 0,
|
|
99
|
-
"resume_count_topup" DECIMAL(20,4) DEFAULT 0,
|
|
100
|
-
"credits_topup" DECIMAL(20,4) DEFAULT 0,
|
|
101
|
-
"interview_ai_assisted_hours_updated" DECIMAL(20,4),
|
|
102
|
-
"interview_full_ai_hours_updated" DECIMAL(20,4),
|
|
103
|
-
"interview_non_ai_hours_updated" DECIMAL(20,4),
|
|
104
|
-
"assignment_count_updated" DECIMAL(20,4),
|
|
105
|
-
"test_count_updated" DECIMAL(20,4),
|
|
106
|
-
"resume_count_updated" DECIMAL(20,4),
|
|
107
|
-
"credits_updated" DECIMAL(20,4),
|
|
108
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
109
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
110
|
-
"created_by" TEXT NOT NULL,
|
|
111
|
-
"updated_by" TEXT NOT NULL,
|
|
112
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
113
|
-
|
|
114
|
-
CONSTRAINT "purchased_hiring_units_pkey" PRIMARY KEY ("id")
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
-- CreateTable
|
|
118
|
-
CREATE TABLE "licensing"."purchased_top_ups" (
|
|
119
|
-
"id" TEXT NOT NULL,
|
|
120
|
-
"organisation_id" TEXT NOT NULL,
|
|
121
|
-
"purchased_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
122
|
-
"status" "licensing"."PurchasedTopUpStatus" NOT NULL DEFAULT 'ACTIVE',
|
|
123
|
-
"total_price" DECIMAL(18,2),
|
|
124
|
-
"currency" TEXT DEFAULT 'INR',
|
|
125
|
-
"description" TEXT,
|
|
126
|
-
"interview_ai_assisted_hours_purchased" DECIMAL(20,4),
|
|
127
|
-
"interview_full_ai_hours_purchased" DECIMAL(20,4),
|
|
128
|
-
"interview_non_ai_hours_purchased" DECIMAL(20,4),
|
|
129
|
-
"assignment_count_purchased" DECIMAL(20,4),
|
|
130
|
-
"test_count_purchased" DECIMAL(20,4),
|
|
131
|
-
"resume_count_purchased" DECIMAL(20,4),
|
|
132
|
-
"credits_purchased" DECIMAL(20,4),
|
|
133
|
-
"interview_ai_assisted_hours_remaining" DECIMAL(20,4),
|
|
134
|
-
"interview_full_ai_hours_remaining" DECIMAL(20,4),
|
|
135
|
-
"interview_non_ai_hours_remaining" DECIMAL(20,4),
|
|
136
|
-
"assignment_count_remaining" DECIMAL(20,4),
|
|
137
|
-
"test_count_remaining" DECIMAL(20,4),
|
|
138
|
-
"resume_count_remaining" DECIMAL(20,4),
|
|
139
|
-
"credits_remaining" DECIMAL(20,4),
|
|
140
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
141
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
142
|
-
"created_by" TEXT NOT NULL,
|
|
143
|
-
"updated_by" TEXT NOT NULL,
|
|
144
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
145
|
-
|
|
146
|
-
CONSTRAINT "purchased_top_ups_pkey" PRIMARY KEY ("id")
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
-- CreateTable
|
|
150
|
-
CREATE TABLE "licensing"."purchased_hiring_unit_assignment_events" (
|
|
151
|
-
"id" TEXT NOT NULL,
|
|
152
|
-
"purchased_hiring_unit_id" TEXT NOT NULL,
|
|
153
|
-
"event_kind" "licensing"."PurchasedHiringUnitAssignmentEventKind" NOT NULL,
|
|
154
|
-
"previous_department_id" TEXT,
|
|
155
|
-
"new_department_id" TEXT,
|
|
156
|
-
"previous_job_description_id" TEXT,
|
|
157
|
-
"new_job_description_id" TEXT,
|
|
158
|
-
"effective_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
159
|
-
"created_by" TEXT NOT NULL,
|
|
160
|
-
|
|
161
|
-
CONSTRAINT "purchased_hiring_unit_assignment_events_pkey" PRIMARY KEY ("id")
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
-- CreateIndex
|
|
165
|
-
CREATE INDEX "license_packages_code_idx" ON "licensing"."license_packages"("code");
|
|
166
|
-
|
|
167
|
-
-- CreateIndex
|
|
168
|
-
CREATE INDEX "license_packages_status_idx" ON "licensing"."license_packages"("status");
|
|
169
|
-
|
|
170
|
-
-- CreateIndex
|
|
171
|
-
CREATE UNIQUE INDEX "license_packages_code_version_key" ON "licensing"."license_packages"("code", "version");
|
|
172
|
-
|
|
173
|
-
-- CreateIndex
|
|
174
|
-
CREATE INDEX "purchased_license_packages_organisation_id_idx" ON "licensing"."purchased_license_packages"("organisation_id");
|
|
175
|
-
|
|
176
|
-
-- CreateIndex
|
|
177
|
-
CREATE INDEX "purchased_license_packages_organisation_id_status_idx" ON "licensing"."purchased_license_packages"("organisation_id", "status");
|
|
178
|
-
|
|
179
|
-
-- CreateIndex
|
|
180
|
-
CREATE INDEX "purchased_license_packages_organisation_id_purchased_at_idx" ON "licensing"."purchased_license_packages"("organisation_id", "purchased_at");
|
|
181
|
-
|
|
182
|
-
-- CreateIndex
|
|
183
|
-
CREATE INDEX "purchased_hiring_units_organisation_id_idx" ON "licensing"."purchased_hiring_units"("organisation_id");
|
|
184
|
-
|
|
185
|
-
-- CreateIndex
|
|
186
|
-
CREATE INDEX "purchased_hiring_units_purchased_license_package_id_idx" ON "licensing"."purchased_hiring_units"("purchased_license_package_id");
|
|
187
|
-
|
|
188
|
-
-- CreateIndex
|
|
189
|
-
CREATE INDEX "purchased_hiring_units_department_id_idx" ON "licensing"."purchased_hiring_units"("department_id");
|
|
190
|
-
|
|
191
|
-
-- CreateIndex
|
|
192
|
-
CREATE INDEX "purchased_hiring_units_job_description_id_idx" ON "licensing"."purchased_hiring_units"("job_description_id");
|
|
193
|
-
|
|
194
|
-
-- CreateIndex
|
|
195
|
-
CREATE INDEX "purchased_hiring_units_organisation_id_status_idx" ON "licensing"."purchased_hiring_units"("organisation_id", "status");
|
|
196
|
-
|
|
197
|
-
-- CreateIndex
|
|
198
|
-
CREATE INDEX "purchased_hiring_units_organisation_id_department_id_idx" ON "licensing"."purchased_hiring_units"("organisation_id", "department_id");
|
|
199
|
-
|
|
200
|
-
-- CreateIndex
|
|
201
|
-
CREATE INDEX "purchased_hiring_units_organisation_id_job_description_id_idx" ON "licensing"."purchased_hiring_units"("organisation_id", "job_description_id");
|
|
202
|
-
|
|
203
|
-
-- CreateIndex
|
|
204
|
-
CREATE INDEX "purchased_top_ups_organisation_id_idx" ON "licensing"."purchased_top_ups"("organisation_id");
|
|
205
|
-
|
|
206
|
-
-- CreateIndex
|
|
207
|
-
CREATE INDEX "purchased_top_ups_organisation_id_status_idx" ON "licensing"."purchased_top_ups"("organisation_id", "status");
|
|
208
|
-
|
|
209
|
-
-- CreateIndex
|
|
210
|
-
CREATE INDEX "purchased_hu_assignment_events_unit_id_idx" ON "licensing"."purchased_hiring_unit_assignment_events"("purchased_hiring_unit_id");
|
|
211
|
-
|
|
212
|
-
-- CreateIndex
|
|
213
|
-
CREATE INDEX "purchased_hu_assignment_events_unit_effective_idx" ON "licensing"."purchased_hiring_unit_assignment_events"("purchased_hiring_unit_id", "effective_at");
|
|
214
|
-
|
|
215
|
-
-- AddForeignKey
|
|
216
|
-
ALTER TABLE "licensing"."purchased_license_packages" ADD CONSTRAINT "purchased_license_packages_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
217
|
-
|
|
218
|
-
-- AddForeignKey
|
|
219
|
-
ALTER TABLE "licensing"."purchased_license_packages" ADD CONSTRAINT "purchased_license_packages_license_package_id_fkey" FOREIGN KEY ("license_package_id") REFERENCES "licensing"."license_packages"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
220
|
-
|
|
221
|
-
-- AddForeignKey
|
|
222
|
-
ALTER TABLE "licensing"."purchased_hiring_units" ADD CONSTRAINT "purchased_hiring_units_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
223
|
-
|
|
224
|
-
-- AddForeignKey
|
|
225
|
-
ALTER TABLE "licensing"."purchased_hiring_units" ADD CONSTRAINT "purchased_hiring_units_purchased_license_package_id_fkey" FOREIGN KEY ("purchased_license_package_id") REFERENCES "licensing"."purchased_license_packages"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
226
|
-
|
|
227
|
-
-- AddForeignKey
|
|
228
|
-
ALTER TABLE "licensing"."purchased_hiring_units" ADD CONSTRAINT "purchased_hiring_units_department_id_fkey" FOREIGN KEY ("department_id") REFERENCES "Department"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
229
|
-
|
|
230
|
-
-- AddForeignKey
|
|
231
|
-
ALTER TABLE "licensing"."purchased_hiring_units" ADD CONSTRAINT "purchased_hiring_units_job_description_id_fkey" FOREIGN KEY ("job_description_id") REFERENCES "JobDescription"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
232
|
-
|
|
233
|
-
-- AddForeignKey
|
|
234
|
-
ALTER TABLE "licensing"."purchased_top_ups" ADD CONSTRAINT "purchased_top_ups_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
235
|
-
|
|
236
|
-
-- AddForeignKey
|
|
237
|
-
ALTER TABLE "licensing"."purchased_hiring_unit_assignment_events" ADD CONSTRAINT "purchased_hiring_unit_assignment_events_purchased_hiring_u_fkey" FOREIGN KEY ("purchased_hiring_unit_id") REFERENCES "licensing"."purchased_hiring_units"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "licensing"."LicensingLedgerEntitlementType" AS ENUM (
|
|
3
|
-
'INTERVIEW_AI_ASSISTED_HOURS',
|
|
4
|
-
'INTERVIEW_FULL_AI_HOURS',
|
|
5
|
-
'INTERVIEW_NON_AI_HOURS',
|
|
6
|
-
'ASSIGNMENT_COUNT',
|
|
7
|
-
'TEST_COUNT',
|
|
8
|
-
'RESUME_COUNT',
|
|
9
|
-
'CREDITS'
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
-- CreateEnum
|
|
13
|
-
CREATE TYPE "licensing"."LicensingLedgerDirection" AS ENUM ('CREDIT', 'DEBIT');
|
|
14
|
-
|
|
15
|
-
-- CreateEnum
|
|
16
|
-
CREATE TYPE "licensing"."LicensingLedgerReason" AS ENUM (
|
|
17
|
-
'PURCHASE',
|
|
18
|
-
'TOP_UP',
|
|
19
|
-
'USAGE',
|
|
20
|
-
'ADJUSTMENT',
|
|
21
|
-
'REFUND',
|
|
22
|
-
'EXPIRY'
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
-- CreateTable
|
|
26
|
-
CREATE TABLE "licensing"."licensing_ledger" (
|
|
27
|
-
"id" TEXT NOT NULL,
|
|
28
|
-
"organisation_id" TEXT NOT NULL,
|
|
29
|
-
"purchased_hiring_unit_id" TEXT,
|
|
30
|
-
"entitlement_type" "licensing"."LicensingLedgerEntitlementType" NOT NULL,
|
|
31
|
-
"direction" "licensing"."LicensingLedgerDirection" NOT NULL,
|
|
32
|
-
"amount" DECIMAL(20,4) NOT NULL,
|
|
33
|
-
"reason" "licensing"."LicensingLedgerReason" NOT NULL,
|
|
34
|
-
"occurred_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
35
|
-
"source_type" TEXT,
|
|
36
|
-
"source_id" TEXT,
|
|
37
|
-
"description" TEXT,
|
|
38
|
-
"idempotency_key" TEXT NOT NULL,
|
|
39
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
40
|
-
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
41
|
-
"created_by" TEXT NOT NULL,
|
|
42
|
-
"updated_by" TEXT NOT NULL,
|
|
43
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
44
|
-
|
|
45
|
-
CONSTRAINT "licensing_ledger_pkey" PRIMARY KEY ("id"),
|
|
46
|
-
CONSTRAINT "licensing_ledger_amount_non_negative" CHECK ("amount" >= 0)
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
-- CreateIndex
|
|
50
|
-
CREATE UNIQUE INDEX "licensing_ledger_idempotency_key_key" ON "licensing"."licensing_ledger"("idempotency_key");
|
|
51
|
-
|
|
52
|
-
-- CreateIndex
|
|
53
|
-
CREATE INDEX "licensing_ledger_unit_type_occurred_idx" ON "licensing"."licensing_ledger"("purchased_hiring_unit_id", "entitlement_type", "occurred_at");
|
|
54
|
-
|
|
55
|
-
-- CreateIndex
|
|
56
|
-
CREATE INDEX "licensing_ledger_org_type_occurred_idx" ON "licensing"."licensing_ledger"("organisation_id", "entitlement_type", "occurred_at");
|
|
57
|
-
|
|
58
|
-
-- AddForeignKey
|
|
59
|
-
ALTER TABLE "licensing"."licensing_ledger" ADD CONSTRAINT "licensing_ledger_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
60
|
-
|
|
61
|
-
-- AddForeignKey
|
|
62
|
-
ALTER TABLE "licensing"."licensing_ledger" ADD CONSTRAINT "licensing_ledger_purchased_hiring_unit_id_fkey" FOREIGN KEY ("purchased_hiring_unit_id") REFERENCES "licensing"."purchased_hiring_units"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
63
|
-
|
|
64
|
-
-- Backfill PURCHASE credits from COALESCE(updated, base) when not null.
|
|
65
|
-
INSERT INTO "licensing"."licensing_ledger" (
|
|
66
|
-
"id",
|
|
67
|
-
"organisation_id",
|
|
68
|
-
"purchased_hiring_unit_id",
|
|
69
|
-
"entitlement_type",
|
|
70
|
-
"direction",
|
|
71
|
-
"amount",
|
|
72
|
-
"reason",
|
|
73
|
-
"occurred_at",
|
|
74
|
-
"source_type",
|
|
75
|
-
"source_id",
|
|
76
|
-
"idempotency_key",
|
|
77
|
-
"created_at",
|
|
78
|
-
"updated_at",
|
|
79
|
-
"created_by",
|
|
80
|
-
"updated_by",
|
|
81
|
-
"is_active"
|
|
82
|
-
)
|
|
83
|
-
SELECT
|
|
84
|
-
gen_random_uuid()::text,
|
|
85
|
-
u."organisation_id",
|
|
86
|
-
u."id",
|
|
87
|
-
stem.entitlement_type::"licensing"."LicensingLedgerEntitlementType",
|
|
88
|
-
'CREDIT'::"licensing"."LicensingLedgerDirection",
|
|
89
|
-
COALESCE(stem.updated_amount, stem.base_amount),
|
|
90
|
-
'PURCHASE'::"licensing"."LicensingLedgerReason",
|
|
91
|
-
u."created_at",
|
|
92
|
-
'purchased_license_package',
|
|
93
|
-
u."purchased_license_package_id",
|
|
94
|
-
'purchase:' || u."id" || ':' || stem.entitlement_type,
|
|
95
|
-
u."created_at",
|
|
96
|
-
u."updated_at",
|
|
97
|
-
u."created_by",
|
|
98
|
-
u."updated_by",
|
|
99
|
-
true
|
|
100
|
-
FROM "licensing"."purchased_hiring_units" u
|
|
101
|
-
CROSS JOIN LATERAL (
|
|
102
|
-
VALUES
|
|
103
|
-
('INTERVIEW_AI_ASSISTED_HOURS', u."interview_ai_assisted_hours", u."interview_ai_assisted_hours_updated"),
|
|
104
|
-
('INTERVIEW_FULL_AI_HOURS', u."interview_full_ai_hours", u."interview_full_ai_hours_updated"),
|
|
105
|
-
('INTERVIEW_NON_AI_HOURS', u."interview_non_ai_hours", u."interview_non_ai_hours_updated"),
|
|
106
|
-
('ASSIGNMENT_COUNT', u."assignment_count", u."assignment_count_updated"),
|
|
107
|
-
('TEST_COUNT', u."test_count", u."test_count_updated"),
|
|
108
|
-
('RESUME_COUNT', u."resume_count", u."resume_count_updated"),
|
|
109
|
-
('CREDITS', u."credits", u."credits_updated")
|
|
110
|
-
) AS stem(entitlement_type, base_amount, updated_amount)
|
|
111
|
-
WHERE COALESCE(stem.updated_amount, stem.base_amount) IS NOT NULL;
|
|
112
|
-
|
|
113
|
-
-- Backfill TOP_UP credits when allocated top-up is greater than zero.
|
|
114
|
-
INSERT INTO "licensing"."licensing_ledger" (
|
|
115
|
-
"id",
|
|
116
|
-
"organisation_id",
|
|
117
|
-
"purchased_hiring_unit_id",
|
|
118
|
-
"entitlement_type",
|
|
119
|
-
"direction",
|
|
120
|
-
"amount",
|
|
121
|
-
"reason",
|
|
122
|
-
"occurred_at",
|
|
123
|
-
"source_type",
|
|
124
|
-
"idempotency_key",
|
|
125
|
-
"created_at",
|
|
126
|
-
"updated_at",
|
|
127
|
-
"created_by",
|
|
128
|
-
"updated_by",
|
|
129
|
-
"is_active"
|
|
130
|
-
)
|
|
131
|
-
SELECT
|
|
132
|
-
gen_random_uuid()::text,
|
|
133
|
-
u."organisation_id",
|
|
134
|
-
u."id",
|
|
135
|
-
stem.entitlement_type::"licensing"."LicensingLedgerEntitlementType",
|
|
136
|
-
'CREDIT'::"licensing"."LicensingLedgerDirection",
|
|
137
|
-
stem.topup_amount,
|
|
138
|
-
'TOP_UP'::"licensing"."LicensingLedgerReason",
|
|
139
|
-
u."updated_at",
|
|
140
|
-
'purchased_top_up',
|
|
141
|
-
'topup-backfill:' || u."id" || ':' || stem.entitlement_type,
|
|
142
|
-
u."created_at",
|
|
143
|
-
u."updated_at",
|
|
144
|
-
u."created_by",
|
|
145
|
-
u."updated_by",
|
|
146
|
-
true
|
|
147
|
-
FROM "licensing"."purchased_hiring_units" u
|
|
148
|
-
CROSS JOIN LATERAL (
|
|
149
|
-
VALUES
|
|
150
|
-
('INTERVIEW_AI_ASSISTED_HOURS', u."interview_ai_assisted_hours_topup"),
|
|
151
|
-
('INTERVIEW_FULL_AI_HOURS', u."interview_full_ai_hours_topup"),
|
|
152
|
-
('INTERVIEW_NON_AI_HOURS', u."interview_non_ai_hours_topup"),
|
|
153
|
-
('ASSIGNMENT_COUNT', u."assignment_count_topup"),
|
|
154
|
-
('TEST_COUNT', u."test_count_topup"),
|
|
155
|
-
('RESUME_COUNT', u."resume_count_topup"),
|
|
156
|
-
('CREDITS', u."credits_topup")
|
|
157
|
-
) AS stem(entitlement_type, topup_amount)
|
|
158
|
-
WHERE stem.topup_amount IS NOT NULL AND stem.topup_amount > 0;
|
|
159
|
-
|
|
160
|
-
-- Backfill USAGE debits when consumed is greater than zero.
|
|
161
|
-
INSERT INTO "licensing"."licensing_ledger" (
|
|
162
|
-
"id",
|
|
163
|
-
"organisation_id",
|
|
164
|
-
"purchased_hiring_unit_id",
|
|
165
|
-
"entitlement_type",
|
|
166
|
-
"direction",
|
|
167
|
-
"amount",
|
|
168
|
-
"reason",
|
|
169
|
-
"occurred_at",
|
|
170
|
-
"source_type",
|
|
171
|
-
"idempotency_key",
|
|
172
|
-
"created_at",
|
|
173
|
-
"updated_at",
|
|
174
|
-
"created_by",
|
|
175
|
-
"updated_by",
|
|
176
|
-
"is_active"
|
|
177
|
-
)
|
|
178
|
-
SELECT
|
|
179
|
-
gen_random_uuid()::text,
|
|
180
|
-
u."organisation_id",
|
|
181
|
-
u."id",
|
|
182
|
-
stem.entitlement_type::"licensing"."LicensingLedgerEntitlementType",
|
|
183
|
-
'DEBIT'::"licensing"."LicensingLedgerDirection",
|
|
184
|
-
stem.consumed_amount,
|
|
185
|
-
'USAGE'::"licensing"."LicensingLedgerReason",
|
|
186
|
-
u."updated_at",
|
|
187
|
-
'usage_ledger',
|
|
188
|
-
'usage-backfill:' || u."id" || ':' || stem.entitlement_type,
|
|
189
|
-
u."created_at",
|
|
190
|
-
u."updated_at",
|
|
191
|
-
u."created_by",
|
|
192
|
-
u."updated_by",
|
|
193
|
-
true
|
|
194
|
-
FROM "licensing"."purchased_hiring_units" u
|
|
195
|
-
CROSS JOIN LATERAL (
|
|
196
|
-
VALUES
|
|
197
|
-
('INTERVIEW_AI_ASSISTED_HOURS', u."interview_ai_assisted_hours_consumed"),
|
|
198
|
-
('INTERVIEW_FULL_AI_HOURS', u."interview_full_ai_hours_consumed"),
|
|
199
|
-
('INTERVIEW_NON_AI_HOURS', u."interview_non_ai_hours_consumed"),
|
|
200
|
-
('ASSIGNMENT_COUNT', u."assignment_count_consumed"),
|
|
201
|
-
('TEST_COUNT', u."test_count_consumed"),
|
|
202
|
-
('RESUME_COUNT', u."resume_count_consumed"),
|
|
203
|
-
('CREDITS', u."credits_consumed")
|
|
204
|
-
) AS stem(entitlement_type, consumed_amount)
|
|
205
|
-
WHERE stem.consumed_amount IS NOT NULL AND stem.consumed_amount > 0;
|
|
206
|
-
|
|
207
|
-
-- Drop the wide balance columns from purchased_hiring_units.
|
|
208
|
-
ALTER TABLE "licensing"."purchased_hiring_units"
|
|
209
|
-
DROP COLUMN "interview_ai_assisted_hours",
|
|
210
|
-
DROP COLUMN "interview_full_ai_hours",
|
|
211
|
-
DROP COLUMN "interview_non_ai_hours",
|
|
212
|
-
DROP COLUMN "assignment_count",
|
|
213
|
-
DROP COLUMN "test_count",
|
|
214
|
-
DROP COLUMN "resume_count",
|
|
215
|
-
DROP COLUMN "credits",
|
|
216
|
-
DROP COLUMN "interview_ai_assisted_hours_consumed",
|
|
217
|
-
DROP COLUMN "interview_full_ai_hours_consumed",
|
|
218
|
-
DROP COLUMN "interview_non_ai_hours_consumed",
|
|
219
|
-
DROP COLUMN "assignment_count_consumed",
|
|
220
|
-
DROP COLUMN "test_count_consumed",
|
|
221
|
-
DROP COLUMN "resume_count_consumed",
|
|
222
|
-
DROP COLUMN "credits_consumed",
|
|
223
|
-
DROP COLUMN "interview_ai_assisted_hours_topup",
|
|
224
|
-
DROP COLUMN "interview_full_ai_hours_topup",
|
|
225
|
-
DROP COLUMN "interview_non_ai_hours_topup",
|
|
226
|
-
DROP COLUMN "assignment_count_topup",
|
|
227
|
-
DROP COLUMN "test_count_topup",
|
|
228
|
-
DROP COLUMN "resume_count_topup",
|
|
229
|
-
DROP COLUMN "credits_topup",
|
|
230
|
-
DROP COLUMN "interview_ai_assisted_hours_updated",
|
|
231
|
-
DROP COLUMN "interview_full_ai_hours_updated",
|
|
232
|
-
DROP COLUMN "interview_non_ai_hours_updated",
|
|
233
|
-
DROP COLUMN "assignment_count_updated",
|
|
234
|
-
DROP COLUMN "test_count_updated",
|
|
235
|
-
DROP COLUMN "resume_count_updated",
|
|
236
|
-
DROP COLUMN "credits_updated";
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
-- AlterTable
|
|
2
|
-
ALTER TABLE "licensing"."license_packages"
|
|
3
|
-
ADD COLUMN "cost_price" DECIMAL(18,2) NOT NULL DEFAULT 0;
|
|
4
|
-
|
|
5
|
-
-- CreateEnum
|
|
6
|
-
CREATE TYPE "licensing"."AiCostLedgerReason" AS ENUM ('USAGE', 'ADJUSTMENT', 'REFUND');
|
|
7
|
-
|
|
8
|
-
-- CreateTable
|
|
9
|
-
CREATE TABLE "licensing"."license_package_organisations" (
|
|
10
|
-
"id" TEXT NOT NULL,
|
|
11
|
-
"license_package_id" TEXT NOT NULL,
|
|
12
|
-
"organisation_id" TEXT NOT NULL,
|
|
13
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
14
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
15
|
-
"created_by" TEXT NOT NULL,
|
|
16
|
-
"updated_by" TEXT NOT NULL,
|
|
17
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
18
|
-
|
|
19
|
-
CONSTRAINT "license_package_organisations_pkey" PRIMARY KEY ("id")
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
-- CreateTable
|
|
23
|
-
CREATE TABLE "licensing"."ai_cost_ledger" (
|
|
24
|
-
"id" TEXT NOT NULL,
|
|
25
|
-
"organisation_id" TEXT NOT NULL,
|
|
26
|
-
"purchased_hiring_unit_id" TEXT NOT NULL,
|
|
27
|
-
"workflow_name" TEXT NOT NULL,
|
|
28
|
-
"direction" "licensing"."LicensingLedgerDirection" NOT NULL,
|
|
29
|
-
"amount" DECIMAL(20,4) NOT NULL,
|
|
30
|
-
"reason" "licensing"."AiCostLedgerReason" NOT NULL,
|
|
31
|
-
"occurred_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
32
|
-
"source_type" TEXT,
|
|
33
|
-
"source_id" TEXT,
|
|
34
|
-
"description" TEXT,
|
|
35
|
-
"idempotency_key" TEXT NOT NULL,
|
|
36
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
37
|
-
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
-
"created_by" TEXT NOT NULL,
|
|
39
|
-
"updated_by" TEXT NOT NULL,
|
|
40
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
41
|
-
|
|
42
|
-
CONSTRAINT "ai_cost_ledger_pkey" PRIMARY KEY ("id"),
|
|
43
|
-
CONSTRAINT "ai_cost_ledger_amount_non_negative" CHECK ("amount" >= 0)
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
-- CreateIndex
|
|
47
|
-
CREATE UNIQUE INDEX "license_package_orgs_pkg_org_key" ON "licensing"."license_package_organisations"("license_package_id", "organisation_id");
|
|
48
|
-
|
|
49
|
-
-- CreateIndex
|
|
50
|
-
CREATE INDEX "license_package_organisations_organisation_id_idx" ON "licensing"."license_package_organisations"("organisation_id");
|
|
51
|
-
|
|
52
|
-
-- CreateIndex
|
|
53
|
-
CREATE UNIQUE INDEX "ai_cost_ledger_idempotency_key_key" ON "licensing"."ai_cost_ledger"("idempotency_key");
|
|
54
|
-
|
|
55
|
-
-- CreateIndex
|
|
56
|
-
CREATE INDEX "ai_cost_ledger_unit_occurred_idx" ON "licensing"."ai_cost_ledger"("purchased_hiring_unit_id", "occurred_at");
|
|
57
|
-
|
|
58
|
-
-- CreateIndex
|
|
59
|
-
CREATE INDEX "ai_cost_ledger_unit_workflow_occurred_idx" ON "licensing"."ai_cost_ledger"("purchased_hiring_unit_id", "workflow_name", "occurred_at");
|
|
60
|
-
|
|
61
|
-
-- CreateIndex
|
|
62
|
-
CREATE INDEX "ai_cost_ledger_org_occurred_idx" ON "licensing"."ai_cost_ledger"("organisation_id", "occurred_at");
|
|
63
|
-
|
|
64
|
-
-- AddForeignKey
|
|
65
|
-
ALTER TABLE "licensing"."license_package_organisations" ADD CONSTRAINT "license_package_organisations_license_package_id_fkey" FOREIGN KEY ("license_package_id") REFERENCES "licensing"."license_packages"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
66
|
-
|
|
67
|
-
-- AddForeignKey
|
|
68
|
-
ALTER TABLE "licensing"."license_package_organisations" ADD CONSTRAINT "license_package_organisations_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
69
|
-
|
|
70
|
-
-- AddForeignKey
|
|
71
|
-
ALTER TABLE "licensing"."ai_cost_ledger" ADD CONSTRAINT "ai_cost_ledger_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
72
|
-
|
|
73
|
-
-- AddForeignKey
|
|
74
|
-
ALTER TABLE "licensing"."ai_cost_ledger" ADD CONSTRAINT "ai_cost_ledger_purchased_hiring_unit_id_fkey" FOREIGN KEY ("purchased_hiring_unit_id") REFERENCES "licensing"."purchased_hiring_units"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|