@adaptware/eagles-db 0.5.45 → 0.5.47
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 +31 -88
- package/client/index-browser.js +25 -81
- package/client/index.d.ts +1163 -5391
- package/client/index.js +31 -88
- package/client/package.json +1 -1
- package/client/schema.prisma +43 -123
- package/client/wasm.js +31 -88
- package/package.json +1 -1
- package/prisma/schema/evaluationPlan.prisma +0 -7
- package/prisma/schema/integration.prisma +0 -1
- package/prisma/schema/migrations/20260907120000_add_resume_ai_intake/migration.sql +20 -0
- package/prisma/schema/migrations/20260908120000_add_resume_jd_tailoring/migration.sql +15 -0
- package/prisma/schema/organisation.prisma +0 -2
- package/prisma/schema/resume.prisma +45 -0
- package/prisma/schema/user.prisma +2 -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/payment/billingTransaction.prisma +0 -83
- package/prisma/schema/payment/paymentWebhookEvent.prisma +0 -28
package/package.json
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/// MCQ / interview round classification on EvaluationPlan and analytics.
|
|
2
|
-
/// ASSESSMENT is the legacy value kept for backward compatibility — do not drop it.
|
|
3
|
-
/// GENERAL_APTITUDE_ASSESSMENT and DOMAIN_KNOWLEDGE_ASSESSMENT are explicit split
|
|
4
|
-
/// types for new aptitude vs domain-knowledge MCQ rounds only.
|
|
5
1
|
enum RoundType {
|
|
6
|
-
/// Legacy MCQ round type; existing plans and analytics may still use this.
|
|
7
2
|
ASSESSMENT
|
|
8
|
-
/// New explicit general-aptitude MCQ round.
|
|
9
3
|
GENERAL_APTITUDE_ASSESSMENT
|
|
10
|
-
/// New explicit domain-knowledge MCQ round.
|
|
11
4
|
DOMAIN_KNOWLEDGE_ASSESSMENT
|
|
12
5
|
INTERVIEW
|
|
13
6
|
ASSIGNMENT
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-- AI resume authoring: lifecycle + intake conversation state on Resume.
|
|
2
|
+
-- All columns nullable; NULL status/origin = legacy/uploaded resume, read as
|
|
3
|
+
-- COMPLETED/UPLOADED by the application layer. No backfill required.
|
|
4
|
+
|
|
5
|
+
-- CreateEnum
|
|
6
|
+
CREATE TYPE "public"."ResumeStatus" AS ENUM ('DRAFT', 'GENERATING', 'COMPLETED');
|
|
7
|
+
|
|
8
|
+
-- CreateEnum
|
|
9
|
+
CREATE TYPE "public"."ResumeOrigin" AS ENUM ('UPLOADED', 'PARSED', 'AI_GENERATED');
|
|
10
|
+
|
|
11
|
+
-- AlterTable
|
|
12
|
+
ALTER TABLE "Resume" ADD COLUMN "status" "public"."ResumeStatus",
|
|
13
|
+
ADD COLUMN "origin" "public"."ResumeOrigin",
|
|
14
|
+
ADD COLUMN "intake_session_id" TEXT,
|
|
15
|
+
ADD COLUMN "conversation_history" JSONB,
|
|
16
|
+
ADD COLUMN "intake_progress" INTEGER,
|
|
17
|
+
ADD COLUMN "orion_execution_id" TEXT;
|
|
18
|
+
|
|
19
|
+
-- CreateIndex
|
|
20
|
+
CREATE INDEX "Resume_user_id_status_idx" ON "Resume"("user_id", "status");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- JD-driven resume tailoring: cached session state on the DRAFT Resume row.
|
|
2
|
+
-- The DRAFT Resume row *is* the tailoring session; there is no separate table.
|
|
3
|
+
-- All columns nullable, no backfill required. Non-tailoring resumes leave them NULL.
|
|
4
|
+
--
|
|
5
|
+
-- `TAILORED` origin is additive only. Postgres 12+ permits ADD VALUE inside the
|
|
6
|
+
-- migration transaction as long as the new value is not also used there.
|
|
7
|
+
|
|
8
|
+
-- AlterEnum
|
|
9
|
+
ALTER TYPE "public"."ResumeOrigin" ADD VALUE 'TAILORED';
|
|
10
|
+
|
|
11
|
+
-- AlterTable
|
|
12
|
+
ALTER TABLE "Resume" ADD COLUMN "tailoring_jd_text" TEXT,
|
|
13
|
+
ADD COLUMN "tailoring_jd_parsed" JSONB,
|
|
14
|
+
ADD COLUMN "tailoring_gap_analysis" JSONB,
|
|
15
|
+
ADD COLUMN "tailoring_draft" JSONB;
|
|
@@ -74,8 +74,6 @@ model Organisation {
|
|
|
74
74
|
licensing_ledger_entries LicensingLedgerEntry[]
|
|
75
75
|
license_package_organisations LicensePackageOrganisation[]
|
|
76
76
|
ai_cost_ledger_entries AiCostLedgerEntry[]
|
|
77
|
-
billing_transactions BillingTransaction[]
|
|
78
|
-
payment_webhook_events PaymentWebhookEvent[]
|
|
79
77
|
|
|
80
78
|
@@index([name])
|
|
81
79
|
@@schema("public")
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/// Lifecycle of an AI-authored resume. Legacy/uploaded rows leave this null.
|
|
2
|
+
enum ResumeStatus {
|
|
3
|
+
DRAFT
|
|
4
|
+
GENERATING
|
|
5
|
+
COMPLETED
|
|
6
|
+
|
|
7
|
+
@@schema("public")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/// How a resume came to exist. Legacy rows leave this null (read as UPLOADED).
|
|
11
|
+
enum ResumeOrigin {
|
|
12
|
+
UPLOADED
|
|
13
|
+
PARSED
|
|
14
|
+
AI_GENERATED
|
|
15
|
+
TAILORED
|
|
16
|
+
|
|
17
|
+
@@schema("public")
|
|
18
|
+
}
|
|
19
|
+
|
|
1
20
|
model Resume {
|
|
2
21
|
id String @id @default(uuid())
|
|
3
22
|
user_id String?
|
|
@@ -34,7 +53,33 @@ model Resume {
|
|
|
34
53
|
candidate_profile CandidateProfile? // one-to-one link
|
|
35
54
|
yearsOfExperience Int?
|
|
36
55
|
|
|
56
|
+
/// Lifecycle for AI-authored resumes. Null for legacy/uploaded rows (treated as COMPLETED).
|
|
57
|
+
status ResumeStatus?
|
|
58
|
+
/// How this resume came to exist. Null for legacy rows (treated as UPLOADED).
|
|
59
|
+
origin ResumeOrigin?
|
|
60
|
+
/// Intake session id echoed to the client so a refresh can resume the conversation.
|
|
61
|
+
intake_session_id String?
|
|
62
|
+
/// Durable copy of the chat transcript for the AI intake; Redis is the hot path.
|
|
63
|
+
conversation_history Json?
|
|
64
|
+
/// Progress 0-100 reported by the ResumeIntake workflow.
|
|
65
|
+
intake_progress Int?
|
|
66
|
+
/// Last Orion execution id for the intake/generate workflow, for tracing.
|
|
67
|
+
orion_execution_id String?
|
|
68
|
+
|
|
69
|
+
/// Raw job description text the candidate pasted to start a tailoring session.
|
|
70
|
+
tailoring_jd_text String?
|
|
71
|
+
/// Cached JobDescriptionParser output; computed once per tailoring session.
|
|
72
|
+
tailoring_jd_parsed Json?
|
|
73
|
+
/// Cached ResumeGapAnalysis output; computed once per tailoring session.
|
|
74
|
+
tailoring_gap_analysis Json?
|
|
75
|
+
/// Working tailoring state: the draft ResumeFormData, tailoring notes, the
|
|
76
|
+
/// pending contradiction awaiting resolution, and the question counter.
|
|
77
|
+
/// Scratch space only — the draft is materialised into `resume_data` when the
|
|
78
|
+
/// candidate saves it.
|
|
79
|
+
tailoring_draft Json?
|
|
80
|
+
|
|
37
81
|
@@index([user_id])
|
|
38
82
|
@@index([file_hash])
|
|
83
|
+
@@index([user_id, status])
|
|
39
84
|
@@schema("public")
|
|
40
85
|
}
|
|
@@ -28,6 +28,8 @@ model User {
|
|
|
28
28
|
created_by String
|
|
29
29
|
updated_by String
|
|
30
30
|
is_active Boolean @default(true)
|
|
31
|
+
/// Set when removed from team (Delete); null for active/inactive-only users.
|
|
32
|
+
deleted_at DateTime?
|
|
31
33
|
is_self_registered Boolean @default(true)
|
|
32
34
|
permission_id String? @unique
|
|
33
35
|
preferences Json? @default("{}")
|
package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
-- Safe to re-run: adds record_kind without breaking existing ongoing evaluations.
|
|
2
|
-
|
|
3
|
-
DO $$ BEGIN
|
|
4
|
-
CREATE TYPE "OngoingEvaluationRecordKind" AS ENUM (
|
|
5
|
-
'AI_RECOMMENDED',
|
|
6
|
-
'PLAN_SELECTED',
|
|
7
|
-
'COMMITTED'
|
|
8
|
-
);
|
|
9
|
-
EXCEPTION
|
|
10
|
-
WHEN duplicate_object THEN NULL;
|
|
11
|
-
END $$;
|
|
12
|
-
|
|
13
|
-
ALTER TABLE "OngoingEvaluation"
|
|
14
|
-
ADD COLUMN IF NOT EXISTS "record_kind" "OngoingEvaluationRecordKind";
|
|
15
|
-
|
|
16
|
-
ALTER TABLE "OngoingEvaluation"
|
|
17
|
-
ALTER COLUMN "evaluation_plan_id" DROP NOT NULL;
|
|
18
|
-
|
|
19
|
-
-- All existing rows are real pipeline rounds — not pre-Proceed drafts.
|
|
20
|
-
UPDATE "OngoingEvaluation"
|
|
21
|
-
SET "record_kind" = 'COMMITTED'
|
|
22
|
-
WHERE "record_kind" IS NULL;
|
|
23
|
-
|
|
24
|
-
CREATE INDEX IF NOT EXISTS "OngoingEvaluation_application_id_record_kind_idx"
|
|
25
|
-
ON "OngoingEvaluation"("application_id", "record_kind");
|
package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
-- Replace record_kind enum with is_committed (null = legacy, false = draft, true = committed).
|
|
2
|
-
|
|
3
|
-
ALTER TABLE "OngoingEvaluation"
|
|
4
|
-
ADD COLUMN IF NOT EXISTS "is_committed" BOOLEAN;
|
|
5
|
-
|
|
6
|
-
UPDATE "OngoingEvaluation"
|
|
7
|
-
SET "is_committed" = false
|
|
8
|
-
WHERE "record_kind" IN ('AI_RECOMMENDED', 'PLAN_SELECTED');
|
|
9
|
-
|
|
10
|
-
UPDATE "OngoingEvaluation"
|
|
11
|
-
SET "is_committed" = true
|
|
12
|
-
WHERE "record_kind" = 'COMMITTED';
|
|
13
|
-
|
|
14
|
-
-- Legacy rows without record_kind stay null (treated as committed in app queries).
|
|
15
|
-
|
|
16
|
-
DROP INDEX IF EXISTS "OngoingEvaluation_application_id_record_kind_idx";
|
|
17
|
-
|
|
18
|
-
ALTER TABLE "OngoingEvaluation"
|
|
19
|
-
DROP COLUMN IF EXISTS "record_kind";
|
|
20
|
-
|
|
21
|
-
DROP TYPE IF EXISTS "OngoingEvaluationRecordKind";
|
|
22
|
-
|
|
23
|
-
CREATE INDEX IF NOT EXISTS "OngoingEvaluation_application_id_is_committed_idx"
|
|
24
|
-
ON "OngoingEvaluation"("application_id", "is_committed");
|
package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
-- AlterTable
|
|
2
|
-
ALTER TABLE "Resume" ADD COLUMN "rendered_export_document_id" TEXT,
|
|
3
|
-
ADD COLUMN "resume_template_id" TEXT;
|
|
4
|
-
|
|
5
|
-
-- CreateIndex
|
|
6
|
-
CREATE UNIQUE INDEX "Resume_rendered_export_document_id_key" ON "Resume"("rendered_export_document_id");
|
|
7
|
-
|
|
8
|
-
-- AddForeignKey
|
|
9
|
-
ALTER TABLE "Resume" ADD CONSTRAINT "Resume_rendered_export_document_id_fkey" FOREIGN KEY ("rendered_export_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
-- AlterTable
|
|
2
|
-
ALTER TABLE "JobDescription" ADD COLUMN "display_html_document_id" TEXT;
|
|
3
|
-
|
|
4
|
-
-- CreateIndex
|
|
5
|
-
CREATE UNIQUE INDEX "JobDescription_display_html_document_id_key" ON "JobDescription"("display_html_document_id");
|
|
6
|
-
|
|
7
|
-
-- AddForeignKey
|
|
8
|
-
ALTER TABLE "JobDescription" ADD CONSTRAINT "JobDescription_display_html_document_id_fkey" FOREIGN KEY ("display_html_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "OfferSubstatus" AS ENUM ('OFFER_CREATED', 'OFFER_SENT', 'VIEWED', 'CHANGE_REQUESTED', 'ACCEPTED', 'DECLINED', 'EXPIRED', 'WITHDRAWN', 'JOINED');
|
|
3
|
-
|
|
4
|
-
-- CreateEnum
|
|
5
|
-
CREATE TYPE "OfferLetterTemplateScope" AS ENUM ('ORGANIZATION', 'JOB');
|
|
6
|
-
|
|
7
|
-
-- CreateEnum
|
|
8
|
-
CREATE TYPE "OfferChangeCategory" AS ENUM ('BUDGET', 'BENEFITS', 'JOINING_DATE', 'ROLE_TITLE', 'LOCATION', 'OTHER');
|
|
9
|
-
|
|
10
|
-
-- CreateEnum
|
|
11
|
-
CREATE TYPE "OfferChangeRequestStatus" AS ENUM ('OPEN', 'ADDRESSED');
|
|
12
|
-
|
|
13
|
-
-- AlterTable
|
|
14
|
-
ALTER TABLE "Application" ADD COLUMN "offer_substatus" "OfferSubstatus";
|
|
15
|
-
|
|
16
|
-
-- CreateTable
|
|
17
|
-
CREATE TABLE "OfferLetterTemplate" (
|
|
18
|
-
"id" TEXT NOT NULL,
|
|
19
|
-
"organisation_id" TEXT NOT NULL,
|
|
20
|
-
"job_description_id" TEXT,
|
|
21
|
-
"name" TEXT NOT NULL,
|
|
22
|
-
"description" TEXT,
|
|
23
|
-
"document_id" TEXT NOT NULL,
|
|
24
|
-
"html_document_id" TEXT,
|
|
25
|
-
"scope" "OfferLetterTemplateScope" NOT NULL DEFAULT 'ORGANIZATION',
|
|
26
|
-
"is_default" BOOLEAN NOT NULL DEFAULT false,
|
|
27
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
28
|
-
"created_by" TEXT NOT NULL,
|
|
29
|
-
"updated_by" TEXT NOT NULL,
|
|
30
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
31
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
32
|
-
|
|
33
|
-
CONSTRAINT "OfferLetterTemplate_pkey" PRIMARY KEY ("id")
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
-- CreateTable
|
|
37
|
-
CREATE TABLE "Offer" (
|
|
38
|
-
"id" TEXT NOT NULL,
|
|
39
|
-
"application_id" TEXT NOT NULL,
|
|
40
|
-
"organisation_id" TEXT NOT NULL,
|
|
41
|
-
"candidate_id" TEXT NOT NULL,
|
|
42
|
-
"job_description_id" TEXT NOT NULL,
|
|
43
|
-
"template_id" TEXT,
|
|
44
|
-
"substatus" "OfferSubstatus" NOT NULL DEFAULT 'OFFER_CREATED',
|
|
45
|
-
"letter_version_count" INTEGER NOT NULL DEFAULT 0,
|
|
46
|
-
"change_request_count" INTEGER NOT NULL DEFAULT 0,
|
|
47
|
-
"terms" JSONB NOT NULL DEFAULT '{}',
|
|
48
|
-
"expires_at" TIMESTAMP(3),
|
|
49
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
50
|
-
"created_by" TEXT NOT NULL,
|
|
51
|
-
"updated_by" TEXT NOT NULL,
|
|
52
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
53
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
54
|
-
|
|
55
|
-
CONSTRAINT "Offer_pkey" PRIMARY KEY ("id")
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
-- CreateTable
|
|
59
|
-
CREATE TABLE "OfferLetter" (
|
|
60
|
-
"id" TEXT NOT NULL,
|
|
61
|
-
"offer_id" TEXT NOT NULL,
|
|
62
|
-
"version" INTEGER NOT NULL,
|
|
63
|
-
"document_id" TEXT NOT NULL,
|
|
64
|
-
"template_id" TEXT,
|
|
65
|
-
"template_document_id" TEXT,
|
|
66
|
-
"sent_at" TIMESTAMP(3),
|
|
67
|
-
"viewed_at" TIMESTAMP(3),
|
|
68
|
-
"change_request_note" TEXT,
|
|
69
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
70
|
-
"created_by" TEXT NOT NULL,
|
|
71
|
-
"updated_by" TEXT NOT NULL,
|
|
72
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
73
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
74
|
-
|
|
75
|
-
CONSTRAINT "OfferLetter_pkey" PRIMARY KEY ("id")
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
-- CreateTable
|
|
79
|
-
CREATE TABLE "OfferChangeRequest" (
|
|
80
|
-
"id" TEXT NOT NULL,
|
|
81
|
-
"offer_id" TEXT NOT NULL,
|
|
82
|
-
"offer_letter_id" TEXT NOT NULL,
|
|
83
|
-
"categories" "OfferChangeCategory"[],
|
|
84
|
-
"note" TEXT,
|
|
85
|
-
"status" "OfferChangeRequestStatus" NOT NULL DEFAULT 'OPEN',
|
|
86
|
-
"created_by" TEXT NOT NULL,
|
|
87
|
-
"updated_by" TEXT NOT NULL,
|
|
88
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
89
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
90
|
-
|
|
91
|
-
CONSTRAINT "OfferChangeRequest_pkey" PRIMARY KEY ("id")
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
-- CreateIndex
|
|
95
|
-
CREATE INDEX "OfferLetterTemplate_organisation_id_scope_idx" ON "OfferLetterTemplate"("organisation_id", "scope");
|
|
96
|
-
|
|
97
|
-
-- CreateIndex
|
|
98
|
-
CREATE INDEX "OfferLetterTemplate_job_description_id_idx" ON "OfferLetterTemplate"("job_description_id");
|
|
99
|
-
|
|
100
|
-
-- CreateIndex
|
|
101
|
-
CREATE INDEX "OfferLetterTemplate_document_id_idx" ON "OfferLetterTemplate"("document_id");
|
|
102
|
-
|
|
103
|
-
-- CreateIndex
|
|
104
|
-
CREATE INDEX "OfferLetterTemplate_html_document_id_idx" ON "OfferLetterTemplate"("html_document_id");
|
|
105
|
-
|
|
106
|
-
-- CreateIndex
|
|
107
|
-
CREATE UNIQUE INDEX "Offer_application_id_key" ON "Offer"("application_id");
|
|
108
|
-
|
|
109
|
-
-- CreateIndex
|
|
110
|
-
CREATE INDEX "Offer_organisation_id_idx" ON "Offer"("organisation_id");
|
|
111
|
-
|
|
112
|
-
-- CreateIndex
|
|
113
|
-
CREATE INDEX "Offer_candidate_id_idx" ON "Offer"("candidate_id");
|
|
114
|
-
|
|
115
|
-
-- CreateIndex
|
|
116
|
-
CREATE INDEX "Offer_job_description_id_idx" ON "Offer"("job_description_id");
|
|
117
|
-
|
|
118
|
-
-- CreateIndex
|
|
119
|
-
CREATE INDEX "Offer_substatus_idx" ON "Offer"("substatus");
|
|
120
|
-
|
|
121
|
-
-- CreateIndex
|
|
122
|
-
CREATE UNIQUE INDEX "OfferLetter_document_id_key" ON "OfferLetter"("document_id");
|
|
123
|
-
|
|
124
|
-
-- CreateIndex
|
|
125
|
-
CREATE INDEX "OfferLetter_offer_id_idx" ON "OfferLetter"("offer_id");
|
|
126
|
-
|
|
127
|
-
-- CreateIndex
|
|
128
|
-
CREATE INDEX "OfferLetter_template_id_idx" ON "OfferLetter"("template_id");
|
|
129
|
-
|
|
130
|
-
-- CreateIndex
|
|
131
|
-
CREATE UNIQUE INDEX "OfferLetter_offer_id_version_key" ON "OfferLetter"("offer_id", "version");
|
|
132
|
-
|
|
133
|
-
-- CreateIndex
|
|
134
|
-
CREATE INDEX "OfferChangeRequest_offer_id_status_idx" ON "OfferChangeRequest"("offer_id", "status");
|
|
135
|
-
|
|
136
|
-
-- CreateIndex
|
|
137
|
-
CREATE INDEX "OfferChangeRequest_offer_letter_id_idx" ON "OfferChangeRequest"("offer_letter_id");
|
|
138
|
-
|
|
139
|
-
-- AddForeignKey
|
|
140
|
-
ALTER TABLE "OfferLetterTemplate" ADD CONSTRAINT "OfferLetterTemplate_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
141
|
-
|
|
142
|
-
-- AddForeignKey
|
|
143
|
-
ALTER TABLE "OfferLetterTemplate" ADD CONSTRAINT "OfferLetterTemplate_job_description_id_fkey" FOREIGN KEY ("job_description_id") REFERENCES "JobDescription"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
144
|
-
|
|
145
|
-
-- AddForeignKey
|
|
146
|
-
ALTER TABLE "OfferLetterTemplate" ADD CONSTRAINT "OfferLetterTemplate_document_id_fkey" FOREIGN KEY ("document_id") REFERENCES "Document"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
147
|
-
|
|
148
|
-
-- AddForeignKey
|
|
149
|
-
ALTER TABLE "OfferLetterTemplate" ADD CONSTRAINT "OfferLetterTemplate_html_document_id_fkey" FOREIGN KEY ("html_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
150
|
-
|
|
151
|
-
-- AddForeignKey
|
|
152
|
-
ALTER TABLE "Offer" ADD CONSTRAINT "Offer_application_id_fkey" FOREIGN KEY ("application_id") REFERENCES "Application"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
153
|
-
|
|
154
|
-
-- AddForeignKey
|
|
155
|
-
ALTER TABLE "Offer" ADD CONSTRAINT "Offer_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
156
|
-
|
|
157
|
-
-- AddForeignKey
|
|
158
|
-
ALTER TABLE "Offer" ADD CONSTRAINT "Offer_candidate_id_fkey" FOREIGN KEY ("candidate_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
159
|
-
|
|
160
|
-
-- AddForeignKey
|
|
161
|
-
ALTER TABLE "Offer" ADD CONSTRAINT "Offer_job_description_id_fkey" FOREIGN KEY ("job_description_id") REFERENCES "JobDescription"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
162
|
-
|
|
163
|
-
-- AddForeignKey
|
|
164
|
-
ALTER TABLE "Offer" ADD CONSTRAINT "Offer_template_id_fkey" FOREIGN KEY ("template_id") REFERENCES "OfferLetterTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
165
|
-
|
|
166
|
-
-- AddForeignKey
|
|
167
|
-
ALTER TABLE "OfferLetter" ADD CONSTRAINT "OfferLetter_offer_id_fkey" FOREIGN KEY ("offer_id") REFERENCES "Offer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
168
|
-
|
|
169
|
-
-- AddForeignKey
|
|
170
|
-
ALTER TABLE "OfferLetter" ADD CONSTRAINT "OfferLetter_document_id_fkey" FOREIGN KEY ("document_id") REFERENCES "Document"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
171
|
-
|
|
172
|
-
-- AddForeignKey
|
|
173
|
-
ALTER TABLE "OfferLetter" ADD CONSTRAINT "OfferLetter_template_id_fkey" FOREIGN KEY ("template_id") REFERENCES "OfferLetterTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
174
|
-
|
|
175
|
-
-- AddForeignKey
|
|
176
|
-
ALTER TABLE "OfferLetter" ADD CONSTRAINT "OfferLetter_template_document_id_fkey" FOREIGN KEY ("template_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
177
|
-
|
|
178
|
-
-- AddForeignKey
|
|
179
|
-
ALTER TABLE "OfferChangeRequest" ADD CONSTRAINT "OfferChangeRequest_offer_id_fkey" FOREIGN KEY ("offer_id") REFERENCES "Offer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
180
|
-
|
|
181
|
-
-- AddForeignKey
|
|
182
|
-
ALTER TABLE "OfferChangeRequest" ADD CONSTRAINT "OfferChangeRequest_offer_letter_id_fkey" FOREIGN KEY ("offer_letter_id") REFERENCES "OfferLetter"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
183
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "WorkMode" AS ENUM ('REMOTE', 'OFFICE', 'HYBRID');
|
|
3
|
-
|
|
4
|
-
-- AlterEnum
|
|
5
|
-
ALTER TYPE "OfferChangeRequestStatus" ADD VALUE 'IN_PROGRESS';
|
|
6
|
-
ALTER TYPE "OfferChangeRequestStatus" ADD VALUE 'REJECTED';
|
|
7
|
-
ALTER TYPE "OfferChangeRequestStatus" ADD VALUE 'WITHDRAWN';
|
|
8
|
-
ALTER TYPE "OfferChangeRequestStatus" ADD VALUE 'EXPIRED';
|
|
9
|
-
|
|
10
|
-
-- AlterTable
|
|
11
|
-
ALTER TABLE "OfferChangeRequest" ADD COLUMN "details" JSONB,
|
|
12
|
-
ADD COLUMN "hr_note" TEXT,
|
|
13
|
-
ADD COLUMN "resolved_at" TIMESTAMP(3);
|
|
@@ -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");
|