@adaptware/eagles-db 0.5.33 → 0.5.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/client/edge.js +231 -11
  2. package/client/index-browser.js +225 -4
  3. package/client/index.d.ts +67169 -46191
  4. package/client/index.js +231 -11
  5. package/client/libquery_engine-darwin.dylib.node +0 -0
  6. package/client/package.json +1 -1
  7. package/client/schema.prisma +454 -105
  8. package/client/wasm.js +231 -11
  9. package/package.json +1 -1
  10. package/prisma/.DS_Store +0 -0
  11. package/prisma/migrations/20260519120000_migrate_shortlisted_to_selected/migration.sql +2 -0
  12. package/prisma/schema/.DS_Store +0 -0
  13. package/prisma/schema/department.prisma +3 -2
  14. package/prisma/schema/jobDescription.prisma +1 -0
  15. package/prisma/schema/licensing/aiCostLedger.prisma +34 -0
  16. package/prisma/schema/licensing/assignmentHistory.prisma +19 -0
  17. package/prisma/schema/licensing/licensePackageCatalog.prisma +62 -0
  18. package/prisma/schema/licensing/licensingEnums.prisma +80 -0
  19. package/prisma/schema/licensing/licensingLedger.prisma +32 -0
  20. package/prisma/schema/licensing/purchasedLicense.prisma +74 -0
  21. package/prisma/schema/licensing/purchasedTopUp.prisma +39 -0
  22. package/prisma/schema/migrations/20260519120000_add_analytics_schema/migration.sql +84 -0
  23. package/prisma/schema/migrations/20260625120000_add_interviewer_analytics/migration.sql +26 -0
  24. package/prisma/schema/migrations/20260629120000_add_user_lifecycle_activity_events/migration.sql +13 -0
  25. package/prisma/schema/migrations/20260629140000_drop_organisation_org_code/migration.sql +2 -0
  26. package/prisma/schema/migrations/20260629160000_employee_codes_dual_interviewer_analytics/migration.sql +87 -0
  27. package/prisma/schema/migrations/20260630120000_add_application_sources/migration.sql +38 -0
  28. package/prisma/schema/migrations/20260701120000_add_source_effectiveness_analytics/migration.sql +40 -0
  29. package/prisma/schema/migrations/20260702120000_add_analytics_daily_tables/migration.sql +232 -0
  30. package/prisma/schema/migrations/20260716120000_evaluation_category_four_values/migration.sql +204 -0
  31. package/prisma/schema/migrations/20260716130000_application_withdrawn_analytics/migration.sql +31 -0
  32. package/prisma/schema/migrations/20260804120000_contact_us_optional_website_subject/migration.sql +3 -0
  33. package/prisma/schema/migrations/20260810120000_add_licensing_schema/migration.sql +237 -0
  34. package/prisma/schema/migrations/20260814153000_add_licensing_ledger/migration.sql +236 -0
  35. package/prisma/schema/migrations/20260828120000_license_package_orgs_cost_price_ai_cost_ledger/migration.sql +74 -0
  36. package/prisma/schema/migrations/20260831120000_ai_cost_ledger_purchase_reason/migration.sql +2 -0
  37. package/prisma/schema/migrations/20260831140000_ai_cost_ledger_nullable_hiring_unit/migration.sql +3 -0
  38. package/prisma/schema/organisation.prisma +6 -0
  39. package/prisma/schema/schema.prisma +1 -1
  40. package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql +0 -25
  41. package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql +0 -24
  42. package/prisma/schema/migrations/20260528120000_drop_job_description_recommendation_config/migration.sql +0 -2
  43. package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql +0 -9
  44. package/prisma/schema/migrations/20260714120000_add_job_description_display_html_document/migration.sql +0 -8
  45. package/prisma/schema/migrations/20260716120000_add_offer_letters/migration.sql +0 -183
  46. package/prisma/schema/migrations/20260716140000_offer_schema_refinements/migration.sql +0 -13
  47. package/prisma/schema/migrations/20260716160000_offer_schema_hardening/migration.sql +0 -95
  48. package/prisma/schema/migrations/20260716180000_offer_letter_template_config/migration.sql +0 -2
  49. package/prisma/schema/migrations/20260716190000_add_evaluation_focus_areas/migration.sql +0 -6
  50. package/prisma/schema/migrations/20260717120000_offer_workflow_approval/migration.sql +0 -30
  51. package/prisma/schema/migrations/20260720120000_offer_letter_template_is_draft/migration.sql +0 -5
  52. package/prisma/schema/migrations/20260720140000_offer_status_split/migration.sql +0 -51
  53. package/prisma/schema/migrations/20260720140001_offer_status_split_backfill/migration.sql +0 -37
  54. package/prisma/schema/migrations/20260722120000_offer_draft_edited_html/migration.sql +0 -13
  55. package/prisma/schema/migrations/20260723150000_offer_withdraw_actor_no_show_reason/migration.sql +0 -10
  56. package/prisma/schema/migrations/20260724120000_open_job_offer_accepted_declined_counts/migration.sql +0 -7
  57. package/prisma/schema/migrations/20260811120000_add_integration_provider_razorpay/migration.sql +0 -6
  58. package/prisma/schema/migrations/20260812120000_add_billing_transactions/migration.sql +0 -49
  59. package/prisma/schema/migrations/20260812130000_drop_billing_transaction_gst_snapshots/migration.sql +0 -3
  60. package/prisma/schema/migrations/20260812180000_billing_transaction_invoice_number/migration.sql +0 -5
  61. package/prisma/schema/migrations/20260813120000_payment_webhooks_gst_refunds/migration.sql +0 -79
  62. package/prisma/schema/migrations/20260813140000_platform_gst_profiles/migration.sql +0 -49
  63. package/prisma/schema/migrations/20260813150000_rename_gst_profiles/migration.sql +0 -53
  64. package/prisma/schema/migrations/20260813160000_remove_gst_billing/migration.sql +0 -16
  65. package/prisma/schema/migrations/20260813170000_billing_licensing_unrecoverable/migration.sql +0 -2
  66. package/prisma/schema/migrations/20260813180000_billing_transaction_payment_method/migration.sql +0 -2
  67. package/prisma/schema/migrations/20260814090000_billing_transaction_purchaser_email/migration.sql +0 -2
  68. package/prisma/schema/migrations/20260816100000_billing_product_organisations/migration.sql +0 -35
  69. package/prisma/schema/migrations/20260816120000_merge_billing_product_organisations/migration.sql +0 -25
  70. package/prisma/schema/migrations/20260817120000_billing_payment_mismatch/migration.sql +0 -7
  71. package/prisma/schema/migrations/20260819120000_billing_product_prices/migration.sql +0 -62
  72. package/prisma/schema/migrations/20260819140000_billing_exchange_rates/migration.sql +0 -25
  73. package/prisma/schema/migrations/20260820120000_billing_transaction_failure_category/migration.sql +0 -31
  74. package/prisma/schema/migrations/20260820130000_backfill_billing_transaction_failure_details/migration.sql +0 -23
  75. package/prisma/schema/migrations/20260820140000_drop_billing_product_price_overrides/migration.sql +0 -2
  76. package/prisma/schema/migrations/20260821120000_drop_billing_product_and_mock_licensing/migration.sql +0 -38
  77. package/prisma/schema/migrations/20260824120000_billing_transaction_purchase_display_name/migration.sql +0 -2
  78. package/prisma/schema/migrations/20260831120000_user_communication_email/migration.sql +0 -6
@@ -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,2 +0,0 @@
1
- -- Add UNRECOVERABLE licensing status for Super Admin–marked unrecoverable activation failures.
2
- ALTER TYPE "public"."BillingLicensingStatus" ADD VALUE 'UNRECOVERABLE';
@@ -1,2 +0,0 @@
1
- -- AlterTable
2
- ALTER TABLE "billing_transactions" ADD COLUMN "payment_method" TEXT;
@@ -1,2 +0,0 @@
1
- -- AlterTable
2
- ALTER TABLE "billing_transactions" ADD COLUMN IF NOT EXISTS "purchaser_email" TEXT;
@@ -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 $$;
@@ -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;
@@ -1,62 +0,0 @@
1
- -- CreateTable
2
- CREATE TABLE "billing_product_prices" (
3
- "id" TEXT NOT NULL,
4
- "product_id" TEXT NOT NULL,
5
- "currency" TEXT NOT NULL,
6
- "amount" INTEGER NOT NULL,
7
- "is_active" BOOLEAN NOT NULL DEFAULT true,
8
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
- "updated_at" TIMESTAMP(3) NOT NULL,
10
-
11
- CONSTRAINT "billing_product_prices_pkey" PRIMARY KEY ("id")
12
- );
13
-
14
- -- CreateTable
15
- CREATE TABLE "billing_product_price_overrides" (
16
- "id" TEXT NOT NULL,
17
- "product_id" TEXT NOT NULL,
18
- "country_code" TEXT NOT NULL,
19
- "currency" TEXT NOT NULL,
20
- "amount" INTEGER NOT NULL,
21
- "is_active" BOOLEAN NOT NULL DEFAULT true,
22
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
23
- "updated_at" TIMESTAMP(3) NOT NULL,
24
-
25
- CONSTRAINT "billing_product_price_overrides_pkey" PRIMARY KEY ("id")
26
- );
27
-
28
- -- CreateIndex
29
- CREATE UNIQUE INDEX "billing_product_prices_product_id_currency_key" ON "billing_product_prices"("product_id", "currency");
30
-
31
- -- CreateIndex
32
- CREATE INDEX "billing_product_prices_product_id_is_active_idx" ON "billing_product_prices"("product_id", "is_active");
33
-
34
- -- CreateIndex
35
- CREATE UNIQUE INDEX "billing_product_price_overrides_product_id_country_code_key" ON "billing_product_price_overrides"("product_id", "country_code");
36
-
37
- -- CreateIndex
38
- CREATE INDEX "billing_product_price_overrides_product_id_is_active_idx" ON "billing_product_price_overrides"("product_id", "is_active");
39
-
40
- -- AddForeignKey
41
- ALTER TABLE "billing_product_prices" ADD CONSTRAINT "billing_product_prices_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "billing_products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
42
-
43
- -- AddForeignKey
44
- ALTER TABLE "billing_product_price_overrides" ADD CONSTRAINT "billing_product_price_overrides_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "billing_products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
45
-
46
- -- Backfill one currency price per existing product from scalar price_amount/currency
47
- -- (already stored in minor units). Scalar columns are retained until callers migrate.
48
- INSERT INTO "billing_product_prices" ("id", "product_id", "currency", "amount", "is_active", "created_at", "updated_at")
49
- SELECT gen_random_uuid()::text,
50
- bp."id",
51
- bp."currency",
52
- bp."price_amount",
53
- bp."is_active",
54
- bp."created_at",
55
- bp."updated_at"
56
- FROM "billing_products" AS bp
57
- WHERE NOT EXISTS (
58
- SELECT 1
59
- FROM "billing_product_prices" AS bpp
60
- WHERE bpp."product_id" = bp."id"
61
- AND bpp."currency" = bp."currency"
62
- );
@@ -1,25 +0,0 @@
1
- -- CreateTable
2
- CREATE TABLE "billing_exchange_rates" (
3
- "id" TEXT NOT NULL,
4
- "from_currency" TEXT NOT NULL,
5
- "to_currency" TEXT NOT NULL,
6
- "rate" DECIMAL(20,10) NOT NULL,
7
- "is_active" BOOLEAN NOT NULL DEFAULT true,
8
- "updated_by" TEXT NOT NULL,
9
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
- "updated_at" TIMESTAMP(3) NOT NULL,
11
-
12
- CONSTRAINT "billing_exchange_rates_pkey" PRIMARY KEY ("id")
13
- );
14
-
15
- -- CreateIndex
16
- CREATE UNIQUE INDEX "billing_exchange_rates_from_currency_to_currency_key" ON "billing_exchange_rates"("from_currency", "to_currency");
17
-
18
- -- CreateIndex
19
- CREATE INDEX "billing_exchange_rates_is_active_idx" ON "billing_exchange_rates"("is_active");
20
-
21
- -- Seed v1 INR ↔ USD rates used by the admin converter (major units).
22
- INSERT INTO "billing_exchange_rates" ("id", "from_currency", "to_currency", "rate", "is_active", "updated_by", "created_at", "updated_at")
23
- VALUES
24
- (gen_random_uuid()::text, 'INR', 'USD', 0.0117000000, true, 'system', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
25
- (gen_random_uuid()::text, 'USD', 'INR', 85.4700854701, true, 'system', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
@@ -1,31 +0,0 @@
1
- -- CreateEnum
2
- CREATE TYPE "BillingTransactionFailureCategory" AS ENUM ('RAZORPAY_ORDER', 'RAZORPAY_PAYMENT', 'LICENSING', 'REFUND', 'INTERNAL');
3
-
4
- -- Add failure_category and migrate enum failure_reason to text detail
5
- ALTER TABLE "billing_transactions" ADD COLUMN "failure_category" "BillingTransactionFailureCategory";
6
- ALTER TABLE "billing_transactions" ADD COLUMN "failure_reason_text" TEXT;
7
-
8
- UPDATE "billing_transactions"
9
- SET
10
- "failure_category" = CASE "failure_reason"::text
11
- WHEN 'RAZORPAY_ORDER_CREATION_FAILED' THEN 'RAZORPAY_ORDER'::"BillingTransactionFailureCategory"
12
- WHEN 'PAYMENT_FAILED' THEN 'RAZORPAY_PAYMENT'::"BillingTransactionFailureCategory"
13
- WHEN 'PAYMENT_CANCELLED' THEN 'RAZORPAY_PAYMENT'::"BillingTransactionFailureCategory"
14
- WHEN 'WEBHOOK_PROCESSING_FAILED' THEN 'INTERNAL'::"BillingTransactionFailureCategory"
15
- WHEN 'LICENSING_GRANT_FAILED' THEN 'LICENSING'::"BillingTransactionFailureCategory"
16
- WHEN 'REFUND_FAILED' THEN 'REFUND'::"BillingTransactionFailureCategory"
17
- END,
18
- "failure_reason_text" = CASE "failure_reason"::text
19
- WHEN 'RAZORPAY_ORDER_CREATION_FAILED' THEN 'Razorpay order creation failed'
20
- WHEN 'PAYMENT_FAILED' THEN 'Payment failed'
21
- WHEN 'PAYMENT_CANCELLED' THEN 'Payment was cancelled'
22
- WHEN 'WEBHOOK_PROCESSING_FAILED' THEN 'Webhook processing failed'
23
- WHEN 'LICENSING_GRANT_FAILED' THEN 'Unable to provision purchased entitlements'
24
- WHEN 'REFUND_FAILED' THEN 'Refund failed'
25
- END
26
- WHERE "failure_reason" IS NOT NULL;
27
-
28
- ALTER TABLE "billing_transactions" DROP COLUMN "failure_reason";
29
- DROP TYPE "BillingTransactionFailureReason";
30
-
31
- ALTER TABLE "billing_transactions" RENAME COLUMN "failure_reason_text" TO "failure_reason";
@@ -1,23 +0,0 @@
1
- -- Historical FAILED rows were stored without failure_category / failure_reason.
2
- UPDATE "billing_transactions"
3
- SET
4
- "failure_category" = 'RAZORPAY_ORDER'::"BillingTransactionFailureCategory",
5
- "failure_reason" = 'Checkout failed before a Razorpay order was created'
6
- WHERE "status" = 'FAILED'
7
- AND "failure_reason" IS NULL
8
- AND "razorpay_order_id" IS NULL;
9
-
10
- UPDATE "billing_transactions"
11
- SET
12
- "failure_category" = 'RAZORPAY_PAYMENT'::"BillingTransactionFailureCategory",
13
- "failure_reason" = 'Payment failed'
14
- WHERE "status" = 'FAILED'
15
- AND "failure_reason" IS NULL
16
- AND "razorpay_order_id" IS NOT NULL;
17
-
18
- UPDATE "billing_transactions"
19
- SET
20
- "failure_category" = 'REFUND'::"BillingTransactionFailureCategory",
21
- "failure_reason" = 'Refund failed'
22
- WHERE "status" = 'REFUND_FAILED'
23
- AND "failure_reason" IS NULL;
@@ -1,2 +0,0 @@
1
- -- DropTable
2
- DROP TABLE IF EXISTS "billing_product_price_overrides";
@@ -1,38 +0,0 @@
1
- -- Preserve all billing_transactions rows.
2
- -- Rename product identity to an opaque purchase_reference (values unchanged).
3
- -- Drop catalog tables and mock licensing column only.
4
-
5
- -- 1. Drop FK + rename product identity column
6
- ALTER TABLE "billing_transactions" DROP CONSTRAINT IF EXISTS "billing_transactions_product_id_fkey";
7
- ALTER TABLE "billing_transactions" RENAME COLUMN "product_id" TO "purchase_reference";
8
- DROP INDEX IF EXISTS "billing_transactions_product_id_idx";
9
- CREATE INDEX "billing_transactions_purchase_reference_idx" ON "billing_transactions"("purchase_reference");
10
-
11
- -- 2. Drop mock licensing columns/indexes
12
- DROP INDEX IF EXISTS "billing_transactions_licensing_status_idx";
13
- ALTER TABLE "billing_transactions" DROP COLUMN IF EXISTS "licensing_status";
14
-
15
- -- 3. Remap mock licensing failure category, then rebuild enum without LICENSING
16
- UPDATE "billing_transactions"
17
- SET "failure_category" = 'INTERNAL'::"BillingTransactionFailureCategory"
18
- WHERE "failure_category" = 'LICENSING'::"BillingTransactionFailureCategory";
19
-
20
- CREATE TYPE "BillingTransactionFailureCategory_new" AS ENUM ('RAZORPAY_ORDER', 'RAZORPAY_PAYMENT', 'REFUND', 'INTERNAL');
21
-
22
- ALTER TABLE "billing_transactions"
23
- ALTER COLUMN "failure_category" TYPE "BillingTransactionFailureCategory_new"
24
- USING ("failure_category"::text::"BillingTransactionFailureCategory_new");
25
-
26
- DROP TYPE "BillingTransactionFailureCategory";
27
- ALTER TYPE "BillingTransactionFailureCategory_new" RENAME TO "BillingTransactionFailureCategory";
28
-
29
- -- 4. Drop catalog tables (order: prices → products)
30
- DROP TABLE IF EXISTS "billing_product_prices";
31
- DROP TABLE IF EXISTS "billing_products";
32
-
33
- -- 5. Drop catalog FX table
34
- DROP TABLE IF EXISTS "billing_exchange_rates";
35
-
36
- -- 6. Drop unused enums
37
- DROP TYPE IF EXISTS "BillingLicensingStatus";
38
- DROP TYPE IF EXISTS "BillingProductType";
@@ -1,2 +0,0 @@
1
- -- AlterTable
2
- ALTER TABLE "billing_transactions" ADD COLUMN IF NOT EXISTS "purchase_display_name" TEXT;
@@ -1,6 +0,0 @@
1
- -- Candidate contact email (separate from login `email`).
2
- ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "communication_email" TEXT;
3
-
4
- UPDATE "User"
5
- SET "communication_email" = "email"
6
- WHERE "communication_email" IS NULL;