@adaptware/eagles-db 0.6.2 → 0.6.5
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 +58 -88
- package/client/index-browser.js +53 -83
- package/client/index.d.ts +8707 -5629
- package/client/index.js +58 -88
- package/client/package.json +1 -1
- package/client/schema.prisma +224 -256
- package/client/wasm.js +58 -88
- package/package.json +1 -1
- package/prisma/schema/consent.prisma +108 -34
- package/prisma/schema/document.prisma +1 -0
- package/prisma/schema/integration.prisma +0 -1
- package/prisma/schema/jobDescription.prisma +38 -37
- package/prisma/schema/migrations/20261006120000_add_jd_restrict_candidate_upload/migration.sql +2 -0
- package/prisma/schema/organisation.prisma +6 -2
- package/prisma/schema/user.prisma +2 -0
- package/client/libquery_engine-darwin.dylib.node +0 -0
- package/client/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
- package/client/query_engine-windows.dll.node +0 -0
- package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql +0 -25
- package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql +0 -24
- package/prisma/schema/migrations/20260528120000_drop_job_description_recommendation_config/migration.sql +0 -2
- package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql +0 -9
- package/prisma/schema/migrations/20260714120000_add_job_description_display_html_document/migration.sql +0 -8
- package/prisma/schema/migrations/20260716120000_add_offer_letters/migration.sql +0 -183
- package/prisma/schema/migrations/20260716140000_offer_schema_refinements/migration.sql +0 -13
- package/prisma/schema/migrations/20260716160000_offer_schema_hardening/migration.sql +0 -95
- package/prisma/schema/migrations/20260716180000_offer_letter_template_config/migration.sql +0 -2
- package/prisma/schema/migrations/20260716190000_add_evaluation_focus_areas/migration.sql +0 -6
- package/prisma/schema/migrations/20260717120000_offer_workflow_approval/migration.sql +0 -30
- package/prisma/schema/migrations/20260720120000_offer_letter_template_is_draft/migration.sql +0 -5
- package/prisma/schema/migrations/20260720140000_offer_status_split/migration.sql +0 -51
- package/prisma/schema/migrations/20260720140001_offer_status_split_backfill/migration.sql +0 -37
- package/prisma/schema/migrations/20260722120000_offer_draft_edited_html/migration.sql +0 -13
- package/prisma/schema/migrations/20260723150000_offer_withdraw_actor_no_show_reason/migration.sql +0 -10
- package/prisma/schema/migrations/20260724120000_open_job_offer_accepted_declined_counts/migration.sql +0 -7
- package/prisma/schema/migrations/20260811120000_add_integration_provider_razorpay/migration.sql +0 -6
- package/prisma/schema/migrations/20260812120000_add_billing_transactions/migration.sql +0 -49
- package/prisma/schema/migrations/20260812130000_drop_billing_transaction_gst_snapshots/migration.sql +0 -3
- package/prisma/schema/migrations/20260812180000_billing_transaction_invoice_number/migration.sql +0 -5
- package/prisma/schema/migrations/20260813120000_payment_webhooks_gst_refunds/migration.sql +0 -79
- package/prisma/schema/migrations/20260813140000_platform_gst_profiles/migration.sql +0 -49
- package/prisma/schema/migrations/20260813150000_rename_gst_profiles/migration.sql +0 -53
- package/prisma/schema/migrations/20260813160000_remove_gst_billing/migration.sql +0 -16
- package/prisma/schema/migrations/20260813170000_billing_licensing_unrecoverable/migration.sql +0 -2
- package/prisma/schema/migrations/20260813180000_billing_transaction_payment_method/migration.sql +0 -2
- package/prisma/schema/migrations/20260814090000_billing_transaction_purchaser_email/migration.sql +0 -2
- package/prisma/schema/migrations/20260816100000_billing_product_organisations/migration.sql +0 -35
- package/prisma/schema/migrations/20260816120000_merge_billing_product_organisations/migration.sql +0 -25
- package/prisma/schema/migrations/20260817120000_billing_payment_mismatch/migration.sql +0 -7
- package/prisma/schema/migrations/20260819120000_billing_product_prices/migration.sql +0 -62
- package/prisma/schema/migrations/20260819140000_billing_exchange_rates/migration.sql +0 -25
- package/prisma/schema/migrations/20260820120000_billing_transaction_failure_category/migration.sql +0 -31
- package/prisma/schema/migrations/20260820130000_backfill_billing_transaction_failure_details/migration.sql +0 -23
- package/prisma/schema/migrations/20260820140000_drop_billing_product_price_overrides/migration.sql +0 -2
- package/prisma/schema/migrations/20260821120000_drop_billing_product_and_mock_licensing/migration.sql +0 -38
- package/prisma/schema/migrations/20260824120000_billing_transaction_purchase_display_name/migration.sql +0 -2
- package/prisma/schema/migrations/20260831120000_user_communication_email/migration.sql +0 -6
- package/prisma/schema/migrations/20260901143000_assessment_question_bank_state/migration.sql +0 -15
- package/prisma/schema/migrations/20260902120000_question_category_two_values/migration.sql +0 -16
- package/prisma/schema/migrations/20260902143000_question_bank_item_key/migration.sql +0 -17
- package/prisma/schema/migrations/20260903120000_split_round_type_assessment/migration.sql +0 -9
- package/prisma/schema/migrations/20260904110000_restore_round_type_assessment_enum/migration.sql +0 -5
- package/prisma/schema/migrations/20260904120000_revert_wrong_split_assessment_round_types/migration.sql +0 -42
- package/prisma/schema/migrations/20260909140000_profile_interview_session/migration.sql +0 -99
- package/prisma/schema/migrations/20260911120000_unify_profile_interview_into_interview/migration.sql +0 -139
- package/prisma/schema/migrations/20260929120000_add_evaluation_type_in_person/migration.sql +0 -2
- package/prisma/schema/payment/billingTransaction.prisma +0 -83
- package/prisma/schema/payment/paymentWebhookEvent.prisma +0 -28
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "OfferLetterStatus" AS ENUM ('ACTIVE', 'SUPERSEDED', 'VOID');
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "OfferWithdrawReason" AS ENUM ('ROLE_CLOSED', 'CANDIDATE_ACCEPTED_ELSEWHERE', 'BUDGET', 'MISFIT', 'OTHER');
|
|
6
|
-
|
|
7
|
-
-- AlterEnum: OfferSubstatus — negotiation substatuses
|
|
8
|
-
ALTER TYPE "OfferSubstatus" ADD VALUE 'CHANGE_UNDER_REVIEW';
|
|
9
|
-
ALTER TYPE "OfferSubstatus" ADD VALUE 'COUNTER_OFFER_SENT';
|
|
10
|
-
|
|
11
|
-
-- AlterEnum: OfferChangeRequestStatus — ADDRESSED → RESOLVED
|
|
12
|
-
ALTER TYPE "OfferChangeRequestStatus" RENAME VALUE 'ADDRESSED' TO 'RESOLVED';
|
|
13
|
-
|
|
14
|
-
-- AlterEnum: ActivityEventType — offer workflow events
|
|
15
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_CREATED';
|
|
16
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_SENT';
|
|
17
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_VIEWED';
|
|
18
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_CHANGE_REQUESTED';
|
|
19
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_CHANGE_UNDER_REVIEW';
|
|
20
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_COUNTER_SENT';
|
|
21
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_ACCEPTED';
|
|
22
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_DECLINED';
|
|
23
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_WITHDRAWN';
|
|
24
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_EXPIRED';
|
|
25
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_JOINED';
|
|
26
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_CHANGE_REQUEST_REJECTED';
|
|
27
|
-
ALTER TYPE "ActivityEventType" ADD VALUE 'OFFER_CHANGE_REQUEST_WITHDRAWN';
|
|
28
|
-
|
|
29
|
-
-- AlterEnum: ActivityEntityType — OFFER
|
|
30
|
-
ALTER TYPE "ActivityEntityType" ADD VALUE 'OFFER';
|
|
31
|
-
|
|
32
|
-
-- AlterTable: OfferLetterTemplate — template version
|
|
33
|
-
ALTER TABLE "OfferLetterTemplate" ADD COLUMN "version" INTEGER NOT NULL DEFAULT 1;
|
|
34
|
-
|
|
35
|
-
-- AlterTable: Offer — analytics, withdrawal, current letter pointer
|
|
36
|
-
ALTER TABLE "Offer" ADD COLUMN "current_offer_letter_id" TEXT,
|
|
37
|
-
ADD COLUMN "sent_at" TIMESTAMP(3),
|
|
38
|
-
ADD COLUMN "responded_at" TIMESTAMP(3),
|
|
39
|
-
ADD COLUMN "accepted_at" TIMESTAMP(3),
|
|
40
|
-
ADD COLUMN "declined_at" TIMESTAMP(3),
|
|
41
|
-
ADD COLUMN "withdrawn_at" TIMESTAMP(3),
|
|
42
|
-
ADD COLUMN "expired_at" TIMESTAMP(3),
|
|
43
|
-
ADD COLUMN "joined_at" TIMESTAMP(3),
|
|
44
|
-
ADD COLUMN "withdraw_reason" "OfferWithdrawReason",
|
|
45
|
-
ADD COLUMN "withdraw_note" TEXT;
|
|
46
|
-
|
|
47
|
-
-- AlterTable: OfferLetter — business lifecycle status + template version snapshot
|
|
48
|
-
ALTER TABLE "OfferLetter" ADD COLUMN "status" "OfferLetterStatus" NOT NULL DEFAULT 'ACTIVE',
|
|
49
|
-
ADD COLUMN "template_version" INTEGER;
|
|
50
|
-
|
|
51
|
-
-- Backfill: letter status — max version ACTIVE, others SUPERSEDED
|
|
52
|
-
UPDATE "OfferLetter" ol
|
|
53
|
-
SET "status" = CASE
|
|
54
|
-
WHEN ol."version" = (
|
|
55
|
-
SELECT MAX(ol2."version")
|
|
56
|
-
FROM "OfferLetter" ol2
|
|
57
|
-
WHERE ol2."offer_id" = ol."offer_id" AND ol2."is_active" = true
|
|
58
|
-
) THEN 'ACTIVE'::"OfferLetterStatus"
|
|
59
|
-
ELSE 'SUPERSEDED'::"OfferLetterStatus"
|
|
60
|
-
END
|
|
61
|
-
WHERE ol."is_active" = true;
|
|
62
|
-
|
|
63
|
-
-- Backfill: current_offer_letter_id = latest active letter by version
|
|
64
|
-
UPDATE "Offer" o
|
|
65
|
-
SET "current_offer_letter_id" = (
|
|
66
|
-
SELECT ol."id"
|
|
67
|
-
FROM "OfferLetter" ol
|
|
68
|
-
WHERE ol."offer_id" = o."id" AND ol."is_active" = true
|
|
69
|
-
ORDER BY ol."version" DESC
|
|
70
|
-
LIMIT 1
|
|
71
|
-
)
|
|
72
|
-
WHERE EXISTS (
|
|
73
|
-
SELECT 1 FROM "OfferLetter" ol WHERE ol."offer_id" = o."id" AND ol."is_active" = true
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
-- Backfill: sent_at from earliest letter sent_at
|
|
77
|
-
UPDATE "Offer" o
|
|
78
|
-
SET "sent_at" = (
|
|
79
|
-
SELECT MIN(ol."sent_at")
|
|
80
|
-
FROM "OfferLetter" ol
|
|
81
|
-
WHERE ol."offer_id" = o."id" AND ol."sent_at" IS NOT NULL
|
|
82
|
-
)
|
|
83
|
-
WHERE o."sent_at" IS NULL
|
|
84
|
-
AND EXISTS (
|
|
85
|
-
SELECT 1 FROM "OfferLetter" ol WHERE ol."offer_id" = o."id" AND ol."sent_at" IS NOT NULL
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
-- CreateIndex
|
|
89
|
-
CREATE INDEX "Offer_organisation_id_substatus_idx" ON "Offer"("organisation_id", "substatus");
|
|
90
|
-
CREATE INDEX "Offer_expires_at_idx" ON "Offer"("expires_at");
|
|
91
|
-
CREATE INDEX "Offer_current_offer_letter_id_idx" ON "Offer"("current_offer_letter_id");
|
|
92
|
-
CREATE INDEX "OfferLetter_offer_id_status_idx" ON "OfferLetter"("offer_id", "status");
|
|
93
|
-
|
|
94
|
-
-- AddForeignKey
|
|
95
|
-
ALTER TABLE "Offer" ADD CONSTRAINT "Offer_current_offer_letter_id_fkey" FOREIGN KEY ("current_offer_letter_id") REFERENCES "OfferLetter"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
-- Add focus_areas alongside legacy topics (backfill copies topics → focus_areas).
|
|
2
|
-
ALTER TABLE "EvaluationPlan"
|
|
3
|
-
ADD COLUMN "focus_areas" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[];
|
|
4
|
-
|
|
5
|
-
ALTER TABLE "OngoingEvaluation"
|
|
6
|
-
ADD COLUMN "focus_areas" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[];
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
-- AlterEnum
|
|
2
|
-
ALTER TYPE "OfferSubstatus" ADD VALUE 'PENDING_APPROVAL' AFTER 'OFFER_CREATED';
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "OfferApprovalStatus" AS ENUM ('PENDING', 'APPROVED', 'REJECTED');
|
|
6
|
-
|
|
7
|
-
-- CreateTable
|
|
8
|
-
CREATE TABLE "OfferApproval" (
|
|
9
|
-
"id" TEXT NOT NULL,
|
|
10
|
-
"offer_id" TEXT NOT NULL,
|
|
11
|
-
"status" "OfferApprovalStatus" NOT NULL DEFAULT 'PENDING',
|
|
12
|
-
"note" TEXT,
|
|
13
|
-
"decided_at" TIMESTAMP(3),
|
|
14
|
-
"decided_by" TEXT,
|
|
15
|
-
"created_by" TEXT NOT NULL,
|
|
16
|
-
"updated_by" TEXT NOT NULL,
|
|
17
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
18
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
19
|
-
|
|
20
|
-
CONSTRAINT "OfferApproval_pkey" PRIMARY KEY ("id")
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
-- CreateIndex
|
|
24
|
-
CREATE INDEX "OfferApproval_offer_id_status_idx" ON "OfferApproval"("offer_id", "status");
|
|
25
|
-
|
|
26
|
-
-- CreateIndex
|
|
27
|
-
CREATE INDEX "OfferApproval_offer_id_created_at_idx" ON "OfferApproval"("offer_id", "created_at");
|
|
28
|
-
|
|
29
|
-
-- AddForeignKey
|
|
30
|
-
ALTER TABLE "OfferApproval" ADD CONSTRAINT "OfferApproval_offer_id_fkey" FOREIGN KEY ("offer_id") REFERENCES "Offer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "OfferStatus" AS ENUM ('OPEN', 'ACCEPTED', 'DECLINED', 'EXPIRED', 'WITHDRAWN', 'JOINED', 'NO_SHOW');
|
|
3
|
-
|
|
4
|
-
-- AlterEnum: ApplicationStatus — offer pipeline stages
|
|
5
|
-
-- Must be committed before OFFER/HIRED are used in UPDATE (see next migration).
|
|
6
|
-
ALTER TYPE "ApplicationStatus" ADD VALUE 'OFFER';
|
|
7
|
-
ALTER TYPE "ApplicationStatus" ADD VALUE 'HIRED';
|
|
8
|
-
|
|
9
|
-
-- AlterTable: Offer — status + no-show
|
|
10
|
-
ALTER TABLE "Offer" ADD COLUMN "status" "OfferStatus" NOT NULL DEFAULT 'OPEN',
|
|
11
|
-
ADD COLUMN "no_show_at" TIMESTAMP(3);
|
|
12
|
-
|
|
13
|
-
-- Backfill Offer.status from legacy substatus outcomes
|
|
14
|
-
UPDATE "Offer"
|
|
15
|
-
SET "status" = CASE
|
|
16
|
-
WHEN "substatus" IN (
|
|
17
|
-
'OFFER_CREATED',
|
|
18
|
-
'PENDING_APPROVAL',
|
|
19
|
-
'OFFER_SENT',
|
|
20
|
-
'VIEWED',
|
|
21
|
-
'CHANGE_REQUESTED',
|
|
22
|
-
'CHANGE_UNDER_REVIEW',
|
|
23
|
-
'COUNTER_OFFER_SENT'
|
|
24
|
-
) THEN 'OPEN'::"OfferStatus"
|
|
25
|
-
WHEN "substatus" = 'ACCEPTED' THEN 'ACCEPTED'::"OfferStatus"
|
|
26
|
-
WHEN "substatus" = 'DECLINED' THEN 'DECLINED'::"OfferStatus"
|
|
27
|
-
WHEN "substatus" = 'EXPIRED' THEN 'EXPIRED'::"OfferStatus"
|
|
28
|
-
WHEN "substatus" = 'WITHDRAWN' THEN 'WITHDRAWN'::"OfferStatus"
|
|
29
|
-
WHEN "substatus" = 'JOINED' THEN 'JOINED'::"OfferStatus"
|
|
30
|
-
ELSE 'OPEN'::"OfferStatus"
|
|
31
|
-
END;
|
|
32
|
-
|
|
33
|
-
-- Clear substatus for terminal outcomes
|
|
34
|
-
UPDATE "Offer"
|
|
35
|
-
SET "substatus" = NULL
|
|
36
|
-
WHERE "status" IN ('ACCEPTED', 'DECLINED', 'EXPIRED', 'WITHDRAWN', 'JOINED');
|
|
37
|
-
|
|
38
|
-
ALTER TABLE "Offer" ALTER COLUMN "substatus" DROP DEFAULT;
|
|
39
|
-
ALTER TABLE "Offer" ALTER COLUMN "substatus" DROP NOT NULL;
|
|
40
|
-
|
|
41
|
-
-- AlterTable: Application — offer_status mirror
|
|
42
|
-
ALTER TABLE "Application" ADD COLUMN "offer_status" "OfferStatus";
|
|
43
|
-
|
|
44
|
-
-- Backfill Application offer mirrors from active offers
|
|
45
|
-
UPDATE "Application" a
|
|
46
|
-
SET
|
|
47
|
-
"offer_status" = o."status",
|
|
48
|
-
"offer_substatus" = o."substatus"
|
|
49
|
-
FROM "Offer" o
|
|
50
|
-
WHERE o."application_id" = a."id"
|
|
51
|
-
AND o."is_active" = true;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
-- ApplicationStatus OFFER/HIRED were added in the prior migration; safe to use after commit.
|
|
2
|
-
|
|
3
|
-
-- Backfill Application pipeline stage
|
|
4
|
-
UPDATE "Application"
|
|
5
|
-
SET "status" = 'HIRED'::"ApplicationStatus"
|
|
6
|
-
WHERE "offer_status" = 'JOINED'::"OfferStatus";
|
|
7
|
-
|
|
8
|
-
UPDATE "Application"
|
|
9
|
-
SET "status" = 'OFFER'::"ApplicationStatus"
|
|
10
|
-
WHERE "offer_status" IS NOT NULL
|
|
11
|
-
AND "offer_status" <> 'JOINED'::"OfferStatus";
|
|
12
|
-
|
|
13
|
-
-- Slim OfferSubstatus: remove terminal values
|
|
14
|
-
CREATE TYPE "OfferSubstatus_new" AS ENUM (
|
|
15
|
-
'OFFER_CREATED',
|
|
16
|
-
'PENDING_APPROVAL',
|
|
17
|
-
'OFFER_SENT',
|
|
18
|
-
'VIEWED',
|
|
19
|
-
'CHANGE_REQUESTED',
|
|
20
|
-
'CHANGE_UNDER_REVIEW',
|
|
21
|
-
'COUNTER_OFFER_SENT'
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
ALTER TABLE "Offer"
|
|
25
|
-
ALTER COLUMN "substatus" TYPE "OfferSubstatus_new"
|
|
26
|
-
USING ("substatus"::text::"OfferSubstatus_new");
|
|
27
|
-
|
|
28
|
-
ALTER TABLE "Application"
|
|
29
|
-
ALTER COLUMN "offer_substatus" TYPE "OfferSubstatus_new"
|
|
30
|
-
USING ("offer_substatus"::text::"OfferSubstatus_new");
|
|
31
|
-
|
|
32
|
-
DROP TYPE "OfferSubstatus";
|
|
33
|
-
ALTER TYPE "OfferSubstatus_new" RENAME TO "OfferSubstatus";
|
|
34
|
-
|
|
35
|
-
-- CreateIndex
|
|
36
|
-
CREATE INDEX "Offer_organisation_id_status_idx" ON "Offer"("organisation_id", "status");
|
|
37
|
-
CREATE INDEX "Offer_status_idx" ON "Offer"("status");
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
-- Offer-scoped draft letter HTML (never mutates OfferLetterTemplate).
|
|
2
|
-
ALTER TABLE "public"."Offer"
|
|
3
|
-
ADD COLUMN "draft_edited_html_document_id" TEXT;
|
|
4
|
-
|
|
5
|
-
CREATE INDEX "Offer_draft_edited_html_document_id_idx"
|
|
6
|
-
ON "public"."Offer"("draft_edited_html_document_id");
|
|
7
|
-
|
|
8
|
-
ALTER TABLE "public"."Offer"
|
|
9
|
-
ADD CONSTRAINT "Offer_draft_edited_html_document_id_fkey"
|
|
10
|
-
FOREIGN KEY ("draft_edited_html_document_id")
|
|
11
|
-
REFERENCES "public"."Document"("id")
|
|
12
|
-
ON DELETE SET NULL
|
|
13
|
-
ON UPDATE CASCADE;
|
package/prisma/schema/migrations/20260723150000_offer_withdraw_actor_no_show_reason/migration.sql
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "public"."OfferWithdrawActor" AS ENUM ('CANDIDATE', 'ORGANISATION');
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "public"."OfferNoShowReason" AS ENUM ('ACCEPTED_ELSEWHERE', 'OTHER');
|
|
6
|
-
|
|
7
|
-
-- AlterTable
|
|
8
|
-
ALTER TABLE "public"."Offer"
|
|
9
|
-
ADD COLUMN "withdraw_actor" "public"."OfferWithdrawActor",
|
|
10
|
-
ADD COLUMN "no_show_reason" "public"."OfferNoShowReason";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ALTER TABLE analytics.open_job_analytics
|
|
2
|
-
ADD COLUMN IF NOT EXISTS offer_accepted_count INT NOT NULL DEFAULT 0,
|
|
3
|
-
ADD COLUMN IF NOT EXISTS offer_declined_count INT NOT NULL DEFAULT 0;
|
|
4
|
-
|
|
5
|
-
ALTER TABLE analytics.open_job_analytics_daily
|
|
6
|
-
ADD COLUMN IF NOT EXISTS offer_accepted_count INT NOT NULL DEFAULT 0,
|
|
7
|
-
ADD COLUMN IF NOT EXISTS offer_declined_count INT NOT NULL DEFAULT 0;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "BillingTransactionStatus" AS ENUM ('INITIATED', 'ORDER_CREATED', 'PAYMENT_PENDING', 'SUCCESS', 'FAILED', 'CANCELLED', 'REFUNDED');
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "BillingTransactionType" AS ENUM ('PURCHASE', 'TOP_UP', 'REFUND');
|
|
6
|
-
|
|
7
|
-
-- CreateEnum
|
|
8
|
-
CREATE TYPE "BillingTransactionFailureReason" AS ENUM ('RAZORPAY_ORDER_CREATION_FAILED', 'PAYMENT_FAILED', 'PAYMENT_CANCELLED', 'WEBHOOK_PROCESSING_FAILED');
|
|
9
|
-
|
|
10
|
-
-- CreateTable
|
|
11
|
-
CREATE TABLE "billing_transactions" (
|
|
12
|
-
"id" TEXT NOT NULL,
|
|
13
|
-
"organisation_id" TEXT NOT NULL,
|
|
14
|
-
"product_id" TEXT NOT NULL,
|
|
15
|
-
"transaction_type" "BillingTransactionType" NOT NULL,
|
|
16
|
-
"status" "BillingTransactionStatus" NOT NULL DEFAULT 'INITIATED',
|
|
17
|
-
"failure_reason" "BillingTransactionFailureReason",
|
|
18
|
-
"amount" INTEGER NOT NULL,
|
|
19
|
-
"tax_amount" INTEGER NOT NULL DEFAULT 0,
|
|
20
|
-
"total_amount" INTEGER NOT NULL,
|
|
21
|
-
"currency" TEXT NOT NULL DEFAULT 'INR',
|
|
22
|
-
"gst_id" TEXT,
|
|
23
|
-
"razorpay_order_id" TEXT,
|
|
24
|
-
"razorpay_payment_id" TEXT,
|
|
25
|
-
"razorpay_subscription_id" TEXT,
|
|
26
|
-
"idempotency_key" TEXT NOT NULL,
|
|
27
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
28
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
29
|
-
|
|
30
|
-
CONSTRAINT "billing_transactions_pkey" PRIMARY KEY ("id")
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
-- CreateIndex
|
|
34
|
-
CREATE UNIQUE INDEX "billing_transactions_idempotency_key_key" ON "billing_transactions"("idempotency_key");
|
|
35
|
-
|
|
36
|
-
-- CreateIndex
|
|
37
|
-
CREATE INDEX "billing_transactions_organisation_id_status_idx" ON "billing_transactions"("organisation_id", "status");
|
|
38
|
-
|
|
39
|
-
-- CreateIndex
|
|
40
|
-
CREATE INDEX "billing_transactions_product_id_idx" ON "billing_transactions"("product_id");
|
|
41
|
-
|
|
42
|
-
-- CreateIndex
|
|
43
|
-
CREATE INDEX "billing_transactions_razorpay_order_id_idx" ON "billing_transactions"("razorpay_order_id");
|
|
44
|
-
|
|
45
|
-
-- AddForeignKey
|
|
46
|
-
ALTER TABLE "billing_transactions" ADD CONSTRAINT "billing_transactions_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
47
|
-
|
|
48
|
-
-- AddForeignKey
|
|
49
|
-
ALTER TABLE "billing_transactions" ADD CONSTRAINT "billing_transactions_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "billing_products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "PaymentWebhookEventStatus" AS ENUM ('RECEIVED', 'PROCESSED', 'FAILED');
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "BillingLicensingStatus" AS ENUM ('PENDING', 'COMPLETED', 'FAILED');
|
|
6
|
-
|
|
7
|
-
-- AlterEnum
|
|
8
|
-
ALTER TYPE "BillingTransactionStatus" ADD VALUE 'REFUND_PENDING';
|
|
9
|
-
ALTER TYPE "BillingTransactionStatus" ADD VALUE 'REFUND_FAILED';
|
|
10
|
-
|
|
11
|
-
-- AlterEnum
|
|
12
|
-
ALTER TYPE "BillingTransactionFailureReason" ADD VALUE 'LICENSING_GRANT_FAILED';
|
|
13
|
-
ALTER TYPE "BillingTransactionFailureReason" ADD VALUE 'REFUND_FAILED';
|
|
14
|
-
|
|
15
|
-
-- CreateTable
|
|
16
|
-
CREATE TABLE "organisation_gst_profiles" (
|
|
17
|
-
"id" TEXT NOT NULL,
|
|
18
|
-
"organisation_id" TEXT NOT NULL,
|
|
19
|
-
"name" TEXT NOT NULL,
|
|
20
|
-
"country_code" TEXT NOT NULL,
|
|
21
|
-
"gstin" TEXT NOT NULL,
|
|
22
|
-
"billing_address" TEXT NOT NULL,
|
|
23
|
-
"state_code" TEXT NOT NULL,
|
|
24
|
-
"is_active" BOOLEAN NOT NULL DEFAULT false,
|
|
25
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
26
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
27
|
-
|
|
28
|
-
CONSTRAINT "organisation_gst_profiles_pkey" PRIMARY KEY ("id")
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
-- CreateTable
|
|
32
|
-
CREATE TABLE "payment_webhook_events" (
|
|
33
|
-
"id" TEXT NOT NULL,
|
|
34
|
-
"organisation_id" TEXT,
|
|
35
|
-
"provider" TEXT NOT NULL,
|
|
36
|
-
"provider_event_id" TEXT NOT NULL,
|
|
37
|
-
"event_type" TEXT NOT NULL,
|
|
38
|
-
"status" "PaymentWebhookEventStatus" NOT NULL DEFAULT 'RECEIVED',
|
|
39
|
-
"billing_transaction_id" TEXT,
|
|
40
|
-
"error_message" TEXT,
|
|
41
|
-
"processed_at" TIMESTAMP(3),
|
|
42
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
43
|
-
|
|
44
|
-
CONSTRAINT "payment_webhook_events_pkey" PRIMARY KEY ("id")
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
-- AlterTable
|
|
48
|
-
ALTER TABLE "billing_transactions" RENAME COLUMN "gst_id" TO "gst_profile_id";
|
|
49
|
-
|
|
50
|
-
-- AlterTable
|
|
51
|
-
ALTER TABLE "billing_transactions" ADD COLUMN "tax_breakdown" JSONB,
|
|
52
|
-
ADD COLUMN "licensing_status" "BillingLicensingStatus",
|
|
53
|
-
ADD COLUMN "refund_reason" TEXT,
|
|
54
|
-
ADD COLUMN "refund_amount" INTEGER,
|
|
55
|
-
ADD COLUMN "razorpay_refund_id" TEXT;
|
|
56
|
-
|
|
57
|
-
-- CreateIndex
|
|
58
|
-
CREATE INDEX "organisation_gst_profiles_organisation_id_is_active_idx" ON "organisation_gst_profiles"("organisation_id", "is_active");
|
|
59
|
-
|
|
60
|
-
-- CreateIndex
|
|
61
|
-
CREATE INDEX "payment_webhook_events_status_created_at_idx" ON "payment_webhook_events"("status", "created_at");
|
|
62
|
-
|
|
63
|
-
-- CreateIndex
|
|
64
|
-
CREATE UNIQUE INDEX "payment_webhook_events_provider_provider_event_id_key" ON "payment_webhook_events"("provider", "provider_event_id");
|
|
65
|
-
|
|
66
|
-
-- CreateIndex
|
|
67
|
-
CREATE INDEX "billing_transactions_licensing_status_idx" ON "billing_transactions"("licensing_status");
|
|
68
|
-
|
|
69
|
-
-- CreateIndex
|
|
70
|
-
CREATE UNIQUE INDEX "billing_transactions_razorpay_payment_id_key" ON "billing_transactions"("razorpay_payment_id");
|
|
71
|
-
|
|
72
|
-
-- AddForeignKey
|
|
73
|
-
ALTER TABLE "organisation_gst_profiles" ADD CONSTRAINT "organisation_gst_profiles_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
74
|
-
|
|
75
|
-
-- AddForeignKey
|
|
76
|
-
ALTER TABLE "payment_webhook_events" ADD CONSTRAINT "payment_webhook_events_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
77
|
-
|
|
78
|
-
-- AddForeignKey
|
|
79
|
-
ALTER TABLE "billing_transactions" ADD CONSTRAINT "billing_transactions_gst_profile_id_fkey" FOREIGN KEY ("gst_profile_id") REFERENCES "organisation_gst_profiles"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
-- Keep a single active Treadspace GST profile if several org-scoped ones exist.
|
|
2
|
-
WITH keep AS (
|
|
3
|
-
SELECT id
|
|
4
|
-
FROM organisation_gst_profiles
|
|
5
|
-
WHERE is_active = true
|
|
6
|
-
ORDER BY updated_at DESC
|
|
7
|
-
LIMIT 1
|
|
8
|
-
)
|
|
9
|
-
UPDATE organisation_gst_profiles
|
|
10
|
-
SET is_active = false
|
|
11
|
-
WHERE is_active = true
|
|
12
|
-
AND id NOT IN (SELECT id FROM keep);
|
|
13
|
-
|
|
14
|
-
-- Drop organisation ownership from GST profiles.
|
|
15
|
-
ALTER TABLE "organisation_gst_profiles" DROP CONSTRAINT "organisation_gst_profiles_organisation_id_fkey";
|
|
16
|
-
|
|
17
|
-
DROP INDEX "organisation_gst_profiles_organisation_id_is_active_idx";
|
|
18
|
-
|
|
19
|
-
ALTER TABLE "organisation_gst_profiles" DROP COLUMN "organisation_id";
|
|
20
|
-
|
|
21
|
-
CREATE INDEX "organisation_gst_profiles_is_active_idx" ON "organisation_gst_profiles"("is_active");
|
|
22
|
-
|
|
23
|
-
-- Platform GST rules (18% tax-exclusive, split CGST/SGST for intrastate).
|
|
24
|
-
CREATE TABLE "billing_gst_config" (
|
|
25
|
-
"id" TEXT NOT NULL,
|
|
26
|
-
"rate_bps" INTEGER NOT NULL DEFAULT 1800,
|
|
27
|
-
"split_intrastate" BOOLEAN NOT NULL DEFAULT true,
|
|
28
|
-
"tax_inclusive" BOOLEAN NOT NULL DEFAULT false,
|
|
29
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
30
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
31
|
-
|
|
32
|
-
CONSTRAINT "billing_gst_config_pkey" PRIMARY KEY ("id")
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
INSERT INTO "billing_gst_config" (
|
|
36
|
-
"id",
|
|
37
|
-
"rate_bps",
|
|
38
|
-
"split_intrastate",
|
|
39
|
-
"tax_inclusive",
|
|
40
|
-
"created_at",
|
|
41
|
-
"updated_at"
|
|
42
|
-
) VALUES (
|
|
43
|
-
'platform',
|
|
44
|
-
1800,
|
|
45
|
-
true,
|
|
46
|
-
false,
|
|
47
|
-
CURRENT_TIMESTAMP,
|
|
48
|
-
CURRENT_TIMESTAMP
|
|
49
|
-
);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
ALTER TABLE "billing_transactions"
|
|
2
|
-
DROP CONSTRAINT IF EXISTS "billing_transactions_gst_profile_id_fkey";
|
|
3
|
-
|
|
4
|
-
DO $$
|
|
5
|
-
BEGIN
|
|
6
|
-
IF to_regclass('public.organisation_gst_profiles') IS NOT NULL
|
|
7
|
-
AND to_regclass('public.gst_profiles') IS NULL THEN
|
|
8
|
-
ALTER TABLE "organisation_gst_profiles" RENAME TO "gst_profiles";
|
|
9
|
-
|
|
10
|
-
IF EXISTS (
|
|
11
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'organisation_gst_profiles_pkey'
|
|
12
|
-
) THEN
|
|
13
|
-
ALTER TABLE "gst_profiles"
|
|
14
|
-
RENAME CONSTRAINT "organisation_gst_profiles_pkey" TO "gst_profiles_pkey";
|
|
15
|
-
END IF;
|
|
16
|
-
|
|
17
|
-
IF EXISTS (
|
|
18
|
-
SELECT 1 FROM pg_class c
|
|
19
|
-
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
20
|
-
WHERE n.nspname = 'public'
|
|
21
|
-
AND c.relname = 'organisation_gst_profiles_is_active_idx'
|
|
22
|
-
) THEN
|
|
23
|
-
ALTER INDEX "organisation_gst_profiles_is_active_idx"
|
|
24
|
-
RENAME TO "gst_profiles_is_active_idx";
|
|
25
|
-
END IF;
|
|
26
|
-
ELSIF to_regclass('public.organisation_gst_profiles') IS NOT NULL
|
|
27
|
-
AND to_regclass('public.gst_profiles') IS NOT NULL THEN
|
|
28
|
-
INSERT INTO "gst_profiles" (
|
|
29
|
-
id, name, country_code, gstin, billing_address, state_code,
|
|
30
|
-
is_active, created_at, updated_at
|
|
31
|
-
)
|
|
32
|
-
SELECT
|
|
33
|
-
id, name, country_code, gstin, billing_address, state_code,
|
|
34
|
-
is_active, created_at, updated_at
|
|
35
|
-
FROM "organisation_gst_profiles"
|
|
36
|
-
ON CONFLICT (id) DO NOTHING;
|
|
37
|
-
|
|
38
|
-
DROP TABLE "organisation_gst_profiles";
|
|
39
|
-
END IF;
|
|
40
|
-
END $$;
|
|
41
|
-
|
|
42
|
-
UPDATE "billing_transactions" bt
|
|
43
|
-
SET "gst_profile_id" = NULL
|
|
44
|
-
WHERE bt."gst_profile_id" IS NOT NULL
|
|
45
|
-
AND to_regclass('public.gst_profiles') IS NOT NULL
|
|
46
|
-
AND NOT EXISTS (
|
|
47
|
-
SELECT 1 FROM "gst_profiles" g WHERE g.id = bt."gst_profile_id"
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
ALTER TABLE "billing_transactions"
|
|
51
|
-
ADD CONSTRAINT "billing_transactions_gst_profile_id_fkey"
|
|
52
|
-
FOREIGN KEY ("gst_profile_id") REFERENCES "gst_profiles"("id")
|
|
53
|
-
ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
-- Preserve the amount actually charged (base + tax) before dropping GST columns.
|
|
2
|
-
UPDATE "billing_transactions"
|
|
3
|
-
SET "amount" = "total_amount"
|
|
4
|
-
WHERE "total_amount" IS NOT NULL
|
|
5
|
-
AND "total_amount" <> "amount";
|
|
6
|
-
|
|
7
|
-
ALTER TABLE "billing_transactions" DROP CONSTRAINT IF EXISTS "billing_transactions_gst_profile_id_fkey";
|
|
8
|
-
|
|
9
|
-
ALTER TABLE "billing_transactions"
|
|
10
|
-
DROP COLUMN IF EXISTS "tax_amount",
|
|
11
|
-
DROP COLUMN IF EXISTS "tax_breakdown",
|
|
12
|
-
DROP COLUMN IF EXISTS "total_amount",
|
|
13
|
-
DROP COLUMN IF EXISTS "gst_profile_id";
|
|
14
|
-
|
|
15
|
-
DROP TABLE IF EXISTS "gst_profiles";
|
|
16
|
-
DROP TABLE IF EXISTS "billing_gst_config";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
-- Join table: assign billing products to organisations.
|
|
2
|
-
-- No rows for a product means it is visible to every organisation.
|
|
3
|
-
|
|
4
|
-
CREATE TABLE IF NOT EXISTS "billing_product_organisations" (
|
|
5
|
-
"id" TEXT NOT NULL,
|
|
6
|
-
"product_id" TEXT NOT NULL,
|
|
7
|
-
"organisation_id" TEXT NOT NULL,
|
|
8
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
-
|
|
10
|
-
CONSTRAINT "billing_product_organisations_pkey" PRIMARY KEY ("id")
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
CREATE UNIQUE INDEX IF NOT EXISTS "billing_product_organisations_product_id_organisation_id_key"
|
|
14
|
-
ON "billing_product_organisations"("product_id", "organisation_id");
|
|
15
|
-
|
|
16
|
-
CREATE INDEX IF NOT EXISTS "billing_product_organisations_organisation_id_idx"
|
|
17
|
-
ON "billing_product_organisations"("organisation_id");
|
|
18
|
-
|
|
19
|
-
DO $$ BEGIN
|
|
20
|
-
ALTER TABLE "billing_product_organisations"
|
|
21
|
-
ADD CONSTRAINT "billing_product_organisations_product_id_fkey"
|
|
22
|
-
FOREIGN KEY ("product_id") REFERENCES "billing_products"("id")
|
|
23
|
-
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
24
|
-
EXCEPTION
|
|
25
|
-
WHEN duplicate_object THEN NULL;
|
|
26
|
-
END $$;
|
|
27
|
-
|
|
28
|
-
DO $$ BEGIN
|
|
29
|
-
ALTER TABLE "billing_product_organisations"
|
|
30
|
-
ADD CONSTRAINT "billing_product_organisations_organisation_id_fkey"
|
|
31
|
-
FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id")
|
|
32
|
-
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
33
|
-
EXCEPTION
|
|
34
|
-
WHEN duplicate_object THEN NULL;
|
|
35
|
-
END $$;
|
package/prisma/schema/migrations/20260816120000_merge_billing_product_organisations/migration.sql
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
-- Fold billing_product_organisations into billing_products.organisation_ids.
|
|
2
|
-
-- Empty array means the product is offered to every organisation.
|
|
3
|
-
|
|
4
|
-
ALTER TABLE "billing_products"
|
|
5
|
-
ADD COLUMN IF NOT EXISTS "organisation_ids" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[];
|
|
6
|
-
|
|
7
|
-
DO $$ BEGIN
|
|
8
|
-
IF EXISTS (
|
|
9
|
-
SELECT 1
|
|
10
|
-
FROM information_schema.tables
|
|
11
|
-
WHERE table_schema = 'public'
|
|
12
|
-
AND table_name = 'billing_product_organisations'
|
|
13
|
-
) THEN
|
|
14
|
-
UPDATE "billing_products" AS bp
|
|
15
|
-
SET "organisation_ids" = sub.ids
|
|
16
|
-
FROM (
|
|
17
|
-
SELECT "product_id", array_agg("organisation_id") AS ids
|
|
18
|
-
FROM "billing_product_organisations"
|
|
19
|
-
GROUP BY "product_id"
|
|
20
|
-
) AS sub
|
|
21
|
-
WHERE bp."id" = sub."product_id";
|
|
22
|
-
END IF;
|
|
23
|
-
END $$;
|
|
24
|
-
|
|
25
|
-
DROP TABLE IF EXISTS "billing_product_organisations";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "public"."BillingPaymentMismatchStatus" AS ENUM ('DETECTED', 'UNFULFILLED');
|
|
3
|
-
|
|
4
|
-
-- AlterTable
|
|
5
|
-
ALTER TABLE "public"."billing_transactions"
|
|
6
|
-
ADD COLUMN "payment_mismatch_status" "public"."BillingPaymentMismatchStatus",
|
|
7
|
-
ADD COLUMN "payment_mismatch_fulfilled_by_id" TEXT;
|