@bash-app/bash-common 30.226.0 → 30.228.0
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/dist/aiApproval.d.ts +25 -0
- package/dist/aiApproval.d.ts.map +1 -1
- package/dist/aiApproval.js +32 -4
- package/dist/aiApproval.js.map +1 -1
- package/dist/extendedSchemas.d.ts +54 -1
- package/dist/extendedSchemas.d.ts.map +1 -1
- package/dist/extendedSchemas.js +22 -0
- package/dist/extendedSchemas.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/__tests__/flyerUtils.test.d.ts +2 -0
- package/dist/utils/__tests__/flyerUtils.test.d.ts.map +1 -0
- package/dist/utils/__tests__/flyerUtils.test.js +49 -0
- package/dist/utils/__tests__/flyerUtils.test.js.map +1 -0
- package/dist/utils/flyerUtils.d.ts +42 -0
- package/dist/utils/flyerUtils.d.ts.map +1 -0
- package/dist/utils/flyerUtils.js +104 -0
- package/dist/utils/flyerUtils.js.map +1 -0
- package/package.json +1 -1
- package/prisma/schema.prisma +319 -50
- package/src/aiApproval.ts +118 -0
- package/src/extendedSchemas.ts +57 -2
- package/src/index.ts +14 -0
- package/src/utils/__tests__/flyerUtils.test.ts +70 -0
- package/src/utils/flyerUtils.ts +137 -0
- package/dist/utils/__tests__/cancellationPolicyRefundResolver.test.d.ts +0 -6
- package/dist/utils/__tests__/cancellationPolicyRefundResolver.test.d.ts.map +0 -1
- package/dist/utils/__tests__/cancellationPolicyRefundResolver.test.js +0 -104
- package/dist/utils/__tests__/cancellationPolicyRefundResolver.test.js.map +0 -1
- package/dist/utils/service/serviceRateDBUtils.d.ts +0 -1
- package/dist/utils/service/serviceRateDBUtils.d.ts.map +0 -1
- package/dist/utils/service/serviceRateDBUtils.js +0 -159
- package/dist/utils/service/serviceRateDBUtils.js.map +0 -1
- package/prisma/migrations/add_bash_availability.sql +0 -53
- package/prisma/migrations/add_bashcash_pricing_to_ticket_tier.sql +0 -15
- package/prisma/migrations/add_bashpoints_purchase_tracking.sql +0 -33
- package/prisma/migrations/add_event_group_allow_auto_join.sql +0 -17
- package/prisma/migrations/add_group_member_status_not_going_maybe.sql +0 -5
- package/prisma/migrations/add_groups_and_momentum.sql +0 -135
- package/prisma/migrations/add_groups_momentum_phase0_4.sql +0 -200
- package/prisma/migrations/add_new_feature_tables.sql +0 -140
- package/prisma/migrations/add_pricing_type_enum.sql +0 -88
- package/prisma/migrations/add_tier_privacy_and_fee_handling.sql +0 -29
- package/prisma/migrations/diagnostic_bashcash_columns.sql +0 -157
- package/prisma/migrations/fix_bashcash_referral_code_schema_mismatch.sql +0 -81
- package/prisma/migrations/rename_bashcash_to_bashpoints.sql +0 -183
- package/prisma/migrations/rename_bashcredits_to_bashpoints.sql +0 -96
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
-- Add PricingType enum for TicketTier
|
|
2
|
-
-- This enum determines whether a ticket tier is priced in USD or BashPoints
|
|
3
|
-
|
|
4
|
-
-- Step 1: Create the enum type
|
|
5
|
-
DO $$
|
|
6
|
-
BEGIN
|
|
7
|
-
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'PricingType') THEN
|
|
8
|
-
CREATE TYPE "PricingType" AS ENUM ('USD', 'BASHPOINTS');
|
|
9
|
-
RAISE NOTICE '✅ Created PricingType enum';
|
|
10
|
-
ELSE
|
|
11
|
-
RAISE NOTICE 'ℹ️ PricingType enum already exists';
|
|
12
|
-
END IF;
|
|
13
|
-
END $$;
|
|
14
|
-
|
|
15
|
-
-- Step 2: Check if column exists as String
|
|
16
|
-
DO $$
|
|
17
|
-
BEGIN
|
|
18
|
-
IF EXISTS (
|
|
19
|
-
SELECT 1 FROM information_schema.columns
|
|
20
|
-
WHERE table_name = 'TicketTier'
|
|
21
|
-
AND column_name = 'pricingType'
|
|
22
|
-
AND data_type = 'text'
|
|
23
|
-
) THEN
|
|
24
|
-
-- Column exists as text, convert to enum
|
|
25
|
-
|
|
26
|
-
-- First, update any invalid values to 'USD'
|
|
27
|
-
UPDATE "TicketTier"
|
|
28
|
-
SET "pricingType" = 'USD'
|
|
29
|
-
WHERE "pricingType" NOT IN ('USD', 'BASHPOINTS');
|
|
30
|
-
|
|
31
|
-
-- Drop the default constraint if it exists
|
|
32
|
-
ALTER TABLE "TicketTier"
|
|
33
|
-
ALTER COLUMN "pricingType" DROP DEFAULT;
|
|
34
|
-
|
|
35
|
-
-- Convert the column to enum type
|
|
36
|
-
ALTER TABLE "TicketTier"
|
|
37
|
-
ALTER COLUMN "pricingType" TYPE "PricingType"
|
|
38
|
-
USING "pricingType"::"PricingType";
|
|
39
|
-
|
|
40
|
-
-- Re-add the default
|
|
41
|
-
ALTER TABLE "TicketTier"
|
|
42
|
-
ALTER COLUMN "pricingType" SET DEFAULT 'USD'::"PricingType";
|
|
43
|
-
|
|
44
|
-
RAISE NOTICE '✅ Converted TicketTier.pricingType from text to PricingType enum';
|
|
45
|
-
ELSIF EXISTS (
|
|
46
|
-
SELECT 1 FROM information_schema.columns
|
|
47
|
-
WHERE table_name = 'TicketTier'
|
|
48
|
-
AND column_name = 'pricingType'
|
|
49
|
-
) THEN
|
|
50
|
-
RAISE NOTICE 'ℹ️ TicketTier.pricingType already exists (might already be enum)';
|
|
51
|
-
ELSE
|
|
52
|
-
-- Column doesn't exist, create it as enum
|
|
53
|
-
ALTER TABLE "TicketTier"
|
|
54
|
-
ADD COLUMN "pricingType" "PricingType" NOT NULL DEFAULT 'USD'::"PricingType";
|
|
55
|
-
|
|
56
|
-
RAISE NOTICE '✅ Added TicketTier.pricingType column as PricingType enum';
|
|
57
|
-
END IF;
|
|
58
|
-
END $$;
|
|
59
|
-
|
|
60
|
-
-- Step 3: Verify priceBashPoints column exists
|
|
61
|
-
DO $$
|
|
62
|
-
BEGIN
|
|
63
|
-
IF NOT EXISTS (
|
|
64
|
-
SELECT 1 FROM information_schema.columns
|
|
65
|
-
WHERE table_name = 'TicketTier' AND column_name = 'priceBashPoints'
|
|
66
|
-
) THEN
|
|
67
|
-
ALTER TABLE "TicketTier" ADD COLUMN "priceBashPoints" INTEGER;
|
|
68
|
-
RAISE NOTICE '✅ Added TicketTier.priceBashPoints column';
|
|
69
|
-
ELSE
|
|
70
|
-
RAISE NOTICE 'ℹ️ TicketTier.priceBashPoints column already exists';
|
|
71
|
-
END IF;
|
|
72
|
-
END $$;
|
|
73
|
-
|
|
74
|
-
-- Step 4: Add helpful comment
|
|
75
|
-
COMMENT ON COLUMN "TicketTier"."pricingType" IS 'Determines payment method: USD (credit card) or BASHPOINTS (peer-to-peer loyalty points)';
|
|
76
|
-
COMMENT ON COLUMN "TicketTier"."priceBashPoints" IS 'Price in BashPoints when pricingType=BASHPOINTS (floating market value set by host)';
|
|
77
|
-
|
|
78
|
-
-- Verification
|
|
79
|
-
SELECT
|
|
80
|
-
column_name,
|
|
81
|
-
data_type,
|
|
82
|
-
udt_name,
|
|
83
|
-
column_default,
|
|
84
|
-
is_nullable
|
|
85
|
-
FROM information_schema.columns
|
|
86
|
-
WHERE table_name = 'TicketTier'
|
|
87
|
-
AND column_name IN ('pricingType', 'priceBashPoints')
|
|
88
|
-
ORDER BY column_name;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
-- Migration: Add tierPrivacy to TicketTier, feeHandling to BashEvent
|
|
2
|
-
-- Required for invite-only tiers and fee handling options.
|
|
3
|
-
-- Idempotent — safe to run multiple times.
|
|
4
|
-
|
|
5
|
-
DO $$ BEGIN
|
|
6
|
-
|
|
7
|
-
-- 1. Add tierPrivacy to TicketTier
|
|
8
|
-
IF NOT EXISTS (
|
|
9
|
-
SELECT 1 FROM information_schema.columns
|
|
10
|
-
WHERE table_name = 'TicketTier' AND column_name = 'tierPrivacy'
|
|
11
|
-
) THEN
|
|
12
|
-
ALTER TABLE "TicketTier" ADD COLUMN "tierPrivacy" TEXT NOT NULL DEFAULT 'Public';
|
|
13
|
-
RAISE NOTICE 'Added tierPrivacy to TicketTier';
|
|
14
|
-
ELSE
|
|
15
|
-
RAISE NOTICE 'Column TicketTier.tierPrivacy already exists — skipping';
|
|
16
|
-
END IF;
|
|
17
|
-
|
|
18
|
-
-- 2. Add feeHandling to BashEvent
|
|
19
|
-
IF NOT EXISTS (
|
|
20
|
-
SELECT 1 FROM information_schema.columns
|
|
21
|
-
WHERE table_name = 'BashEvent' AND column_name = 'feeHandling'
|
|
22
|
-
) THEN
|
|
23
|
-
ALTER TABLE "BashEvent" ADD COLUMN "feeHandling" TEXT NOT NULL DEFAULT 'GuestPays';
|
|
24
|
-
RAISE NOTICE 'Added feeHandling to BashEvent';
|
|
25
|
-
ELSE
|
|
26
|
-
RAISE NOTICE 'Column BashEvent.feeHandling already exists — skipping';
|
|
27
|
-
END IF;
|
|
28
|
-
|
|
29
|
-
END $$;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
-- Diagnostic Script: Check Current BashCash/BashPoints Column Names
|
|
2
|
-
-- Run this first to see what exists in your database
|
|
3
|
-
|
|
4
|
-
-- =====================================================================
|
|
5
|
-
-- CHECK FOR BASHCASH COLUMNS
|
|
6
|
-
-- =====================================================================
|
|
7
|
-
|
|
8
|
-
SELECT
|
|
9
|
-
'🔍 Columns containing "bashcash" (old naming)' AS check_type;
|
|
10
|
-
|
|
11
|
-
SELECT
|
|
12
|
-
table_name,
|
|
13
|
-
column_name,
|
|
14
|
-
data_type,
|
|
15
|
-
is_nullable
|
|
16
|
-
FROM information_schema.columns
|
|
17
|
-
WHERE column_name ILIKE '%bashcash%'
|
|
18
|
-
ORDER BY table_name, column_name;
|
|
19
|
-
|
|
20
|
-
-- =====================================================================
|
|
21
|
-
-- CHECK FOR BASHPOINTS COLUMNS
|
|
22
|
-
-- =====================================================================
|
|
23
|
-
|
|
24
|
-
SELECT
|
|
25
|
-
'✅ Columns containing "bashpoints" (new naming)' AS check_type;
|
|
26
|
-
|
|
27
|
-
SELECT
|
|
28
|
-
table_name,
|
|
29
|
-
column_name,
|
|
30
|
-
data_type,
|
|
31
|
-
is_nullable
|
|
32
|
-
FROM information_schema.columns
|
|
33
|
-
WHERE column_name ILIKE '%bashpoints%'
|
|
34
|
-
ORDER BY table_name, column_name;
|
|
35
|
-
|
|
36
|
-
-- =====================================================================
|
|
37
|
-
-- CHECK TICKET TIER COLUMNS
|
|
38
|
-
-- =====================================================================
|
|
39
|
-
|
|
40
|
-
SELECT
|
|
41
|
-
'🎫 TicketTier columns' AS check_type;
|
|
42
|
-
|
|
43
|
-
SELECT
|
|
44
|
-
column_name,
|
|
45
|
-
data_type,
|
|
46
|
-
is_nullable
|
|
47
|
-
FROM information_schema.columns
|
|
48
|
-
WHERE table_name = 'TicketTier'
|
|
49
|
-
ORDER BY ordinal_position;
|
|
50
|
-
|
|
51
|
-
-- =====================================================================
|
|
52
|
-
-- CHECK USER COLUMNS
|
|
53
|
-
-- =====================================================================
|
|
54
|
-
|
|
55
|
-
SELECT
|
|
56
|
-
'👤 User columns (bash-related)' AS check_type;
|
|
57
|
-
|
|
58
|
-
SELECT
|
|
59
|
-
column_name,
|
|
60
|
-
data_type,
|
|
61
|
-
is_nullable
|
|
62
|
-
FROM information_schema.columns
|
|
63
|
-
WHERE table_name = 'User' AND column_name ILIKE '%bash%'
|
|
64
|
-
ORDER BY ordinal_position;
|
|
65
|
-
|
|
66
|
-
-- =====================================================================
|
|
67
|
-
-- CHECK SERVICE COLUMNS
|
|
68
|
-
-- =====================================================================
|
|
69
|
-
|
|
70
|
-
SELECT
|
|
71
|
-
'🛎️ Service columns (bash-related)' AS check_type;
|
|
72
|
-
|
|
73
|
-
SELECT
|
|
74
|
-
column_name,
|
|
75
|
-
data_type,
|
|
76
|
-
is_nullable
|
|
77
|
-
FROM information_schema.columns
|
|
78
|
-
WHERE table_name = 'Service' AND column_name ILIKE '%bash%'
|
|
79
|
-
ORDER BY ordinal_position;
|
|
80
|
-
|
|
81
|
-
-- =====================================================================
|
|
82
|
-
-- CHECK SERVICEBOOKING COLUMNS
|
|
83
|
-
-- =====================================================================
|
|
84
|
-
|
|
85
|
-
SELECT
|
|
86
|
-
'📅 ServiceBooking columns (bash-related)' AS check_type;
|
|
87
|
-
|
|
88
|
-
SELECT
|
|
89
|
-
column_name,
|
|
90
|
-
data_type,
|
|
91
|
-
is_nullable
|
|
92
|
-
FROM information_schema.columns
|
|
93
|
-
WHERE table_name = 'ServiceBooking' AND column_name ILIKE '%bash%'
|
|
94
|
-
ORDER BY ordinal_position;
|
|
95
|
-
|
|
96
|
-
-- =====================================================================
|
|
97
|
-
-- CHECK NOTIFICATION COLUMNS
|
|
98
|
-
-- =====================================================================
|
|
99
|
-
|
|
100
|
-
SELECT
|
|
101
|
-
'🔔 Notification columns (bash-related)' AS check_type;
|
|
102
|
-
|
|
103
|
-
SELECT
|
|
104
|
-
column_name,
|
|
105
|
-
data_type,
|
|
106
|
-
is_nullable
|
|
107
|
-
FROM information_schema.columns
|
|
108
|
-
WHERE table_name = 'Notification' AND column_name ILIKE '%bash%'
|
|
109
|
-
ORDER BY ordinal_position;
|
|
110
|
-
|
|
111
|
-
-- =====================================================================
|
|
112
|
-
-- CHECK PRIZEPAYMENT COLUMNS
|
|
113
|
-
-- =====================================================================
|
|
114
|
-
|
|
115
|
-
SELECT
|
|
116
|
-
'🏆 PrizePayment columns (bash-related)' AS check_type;
|
|
117
|
-
|
|
118
|
-
SELECT
|
|
119
|
-
column_name,
|
|
120
|
-
data_type,
|
|
121
|
-
is_nullable
|
|
122
|
-
FROM information_schema.columns
|
|
123
|
-
WHERE table_name = 'PrizePayment' AND column_name ILIKE '%bash%'
|
|
124
|
-
ORDER BY ordinal_position;
|
|
125
|
-
|
|
126
|
-
-- =====================================================================
|
|
127
|
-
-- CHECK ENUM VALUES
|
|
128
|
-
-- =====================================================================
|
|
129
|
-
|
|
130
|
-
SELECT
|
|
131
|
-
'📋 Enum values containing "bash"' AS check_type;
|
|
132
|
-
|
|
133
|
-
SELECT
|
|
134
|
-
t.typname AS enum_type,
|
|
135
|
-
e.enumlabel AS enum_value,
|
|
136
|
-
e.enumsortorder AS sort_order
|
|
137
|
-
FROM pg_enum e
|
|
138
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
139
|
-
WHERE e.enumlabel ILIKE '%bash%'
|
|
140
|
-
ORDER BY t.typname, e.enumsortorder;
|
|
141
|
-
|
|
142
|
-
-- =====================================================================
|
|
143
|
-
-- SUMMARY
|
|
144
|
-
-- =====================================================================
|
|
145
|
-
|
|
146
|
-
SELECT
|
|
147
|
-
'📊 SUMMARY' AS info;
|
|
148
|
-
|
|
149
|
-
SELECT
|
|
150
|
-
COUNT(*) AS bashcash_columns_count
|
|
151
|
-
FROM information_schema.columns
|
|
152
|
-
WHERE column_name ILIKE '%bashcash%';
|
|
153
|
-
|
|
154
|
-
SELECT
|
|
155
|
-
COUNT(*) AS bashpoints_columns_count
|
|
156
|
-
FROM information_schema.columns
|
|
157
|
-
WHERE column_name ILIKE '%bashpoints%';
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
-- Migration: Fix BashCash Referral Code Schema Mismatch
|
|
2
|
-
-- Date: 2026-02-01
|
|
3
|
-
-- Description: This script verifies that the database column was properly renamed
|
|
4
|
-
-- from bashCashReferralCode to bashPointsReferralCode.
|
|
5
|
-
-- After running this, you MUST update the Prisma schema to match.
|
|
6
|
-
|
|
7
|
-
-- =====================================================================
|
|
8
|
-
-- DIAGNOSTIC: Check current state
|
|
9
|
-
-- =====================================================================
|
|
10
|
-
|
|
11
|
-
-- Check if old column name still exists
|
|
12
|
-
SELECT
|
|
13
|
-
CASE
|
|
14
|
-
WHEN EXISTS (
|
|
15
|
-
SELECT 1 FROM information_schema.columns
|
|
16
|
-
WHERE table_name = 'User' AND column_name = 'bashCashReferralCode'
|
|
17
|
-
) THEN '❌ OLD COLUMN STILL EXISTS: User.bashCashReferralCode'
|
|
18
|
-
ELSE '✅ Old column does not exist (good!)'
|
|
19
|
-
END AS old_column_status;
|
|
20
|
-
|
|
21
|
-
-- Check if new column name exists
|
|
22
|
-
SELECT
|
|
23
|
-
CASE
|
|
24
|
-
WHEN EXISTS (
|
|
25
|
-
SELECT 1 FROM information_schema.columns
|
|
26
|
-
WHERE table_name = 'User' AND column_name = 'bashPointsReferralCode'
|
|
27
|
-
) THEN '✅ NEW COLUMN EXISTS: User.bashPointsReferralCode'
|
|
28
|
-
ELSE '❌ New column does not exist (needs migration!)'
|
|
29
|
-
END AS new_column_status;
|
|
30
|
-
|
|
31
|
-
-- =====================================================================
|
|
32
|
-
-- FIX: Rename column if it hasn't been renamed yet
|
|
33
|
-
-- =====================================================================
|
|
34
|
-
|
|
35
|
-
DO $$
|
|
36
|
-
BEGIN
|
|
37
|
-
-- If the old column still exists, rename it
|
|
38
|
-
IF EXISTS (
|
|
39
|
-
SELECT 1 FROM information_schema.columns
|
|
40
|
-
WHERE table_name = 'User' AND column_name = 'bashCashReferralCode'
|
|
41
|
-
) THEN
|
|
42
|
-
-- Rename the column
|
|
43
|
-
ALTER TABLE "User" RENAME COLUMN "bashCashReferralCode" TO "bashPointsReferralCode";
|
|
44
|
-
RAISE NOTICE '✅ Renamed User.bashCashReferralCode → bashPointsReferralCode';
|
|
45
|
-
|
|
46
|
-
-- Check if there's a unique constraint with the old name and rename it
|
|
47
|
-
IF EXISTS (
|
|
48
|
-
SELECT 1 FROM pg_constraint
|
|
49
|
-
WHERE conname = 'User_bashCashReferralCode_key'
|
|
50
|
-
) THEN
|
|
51
|
-
ALTER TABLE "User" RENAME CONSTRAINT "User_bashCashReferralCode_key" TO "User_bashPointsReferralCode_key";
|
|
52
|
-
RAISE NOTICE '✅ Renamed constraint User_bashCashReferralCode_key → User_bashPointsReferralCode_key';
|
|
53
|
-
END IF;
|
|
54
|
-
ELSE
|
|
55
|
-
RAISE NOTICE 'ℹ️ Column User.bashCashReferralCode already renamed to bashPointsReferralCode';
|
|
56
|
-
END IF;
|
|
57
|
-
END $$;
|
|
58
|
-
|
|
59
|
-
-- =====================================================================
|
|
60
|
-
-- VERIFICATION: Show final state
|
|
61
|
-
-- =====================================================================
|
|
62
|
-
|
|
63
|
-
SELECT
|
|
64
|
-
table_name,
|
|
65
|
-
column_name,
|
|
66
|
-
data_type,
|
|
67
|
-
is_nullable,
|
|
68
|
-
column_default
|
|
69
|
-
FROM information_schema.columns
|
|
70
|
-
WHERE table_name = 'User'
|
|
71
|
-
AND (column_name LIKE '%referral%' OR column_name LIKE '%bashpoints%' OR column_name LIKE '%bashcash%')
|
|
72
|
-
ORDER BY column_name;
|
|
73
|
-
|
|
74
|
-
-- Show constraints
|
|
75
|
-
SELECT
|
|
76
|
-
conname AS constraint_name,
|
|
77
|
-
contype AS constraint_type
|
|
78
|
-
FROM pg_constraint
|
|
79
|
-
WHERE conrelid = 'User'::regclass
|
|
80
|
-
AND conname LIKE '%referral%'
|
|
81
|
-
ORDER BY conname;
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
-- Migration: Rename BashCash to BashPoints (SAFE VERSION)
|
|
2
|
-
-- Date: 2026-01-31
|
|
3
|
-
-- Description: Renames all database columns and enums containing "BashCash" to "BashPoints"
|
|
4
|
-
-- This version checks if columns/enums exist before attempting to rename them
|
|
5
|
-
|
|
6
|
-
-- =====================================================================
|
|
7
|
-
-- SAFE COLUMN RENAMES (Only renames if column exists)
|
|
8
|
-
-- =====================================================================
|
|
9
|
-
|
|
10
|
-
-- 1. TicketTier: Rename priceBashCash to priceBashPoints
|
|
11
|
-
DO $$
|
|
12
|
-
BEGIN
|
|
13
|
-
IF EXISTS (
|
|
14
|
-
SELECT 1 FROM information_schema.columns
|
|
15
|
-
WHERE table_name = 'TicketTier' AND column_name = 'priceBashCash'
|
|
16
|
-
) THEN
|
|
17
|
-
ALTER TABLE "TicketTier" RENAME COLUMN "priceBashCash" TO "priceBashPoints";
|
|
18
|
-
RAISE NOTICE '✅ Renamed TicketTier.priceBashCash → priceBashPoints';
|
|
19
|
-
ELSE
|
|
20
|
-
RAISE NOTICE 'ℹ️ Column TicketTier.priceBashCash already renamed or does not exist';
|
|
21
|
-
END IF;
|
|
22
|
-
END $$;
|
|
23
|
-
|
|
24
|
-
-- 2. User: Rename bashCashReferralCode to bashPointsReferralCode
|
|
25
|
-
DO $$
|
|
26
|
-
BEGIN
|
|
27
|
-
IF EXISTS (
|
|
28
|
-
SELECT 1 FROM information_schema.columns
|
|
29
|
-
WHERE table_name = 'User' AND column_name = 'bashCashReferralCode'
|
|
30
|
-
) THEN
|
|
31
|
-
ALTER TABLE "User" RENAME COLUMN "bashCashReferralCode" TO "bashPointsReferralCode";
|
|
32
|
-
RAISE NOTICE '✅ Renamed User.bashCashReferralCode → bashPointsReferralCode';
|
|
33
|
-
ELSE
|
|
34
|
-
RAISE NOTICE 'ℹ️ Column User.bashCashReferralCode already renamed or does not exist';
|
|
35
|
-
END IF;
|
|
36
|
-
END $$;
|
|
37
|
-
|
|
38
|
-
-- 3. Notification: Rename bashCashTransactionId to bashPointsTransactionId
|
|
39
|
-
DO $$
|
|
40
|
-
BEGIN
|
|
41
|
-
IF EXISTS (
|
|
42
|
-
SELECT 1 FROM information_schema.columns
|
|
43
|
-
WHERE table_name = 'Notification' AND column_name = 'bashCashTransactionId'
|
|
44
|
-
) THEN
|
|
45
|
-
ALTER TABLE "Notification" RENAME COLUMN "bashCashTransactionId" TO "bashPointsTransactionId";
|
|
46
|
-
RAISE NOTICE '✅ Renamed Notification.bashCashTransactionId → bashPointsTransactionId';
|
|
47
|
-
ELSE
|
|
48
|
-
RAISE NOTICE 'ℹ️ Column Notification.bashCashTransactionId already renamed or does not exist';
|
|
49
|
-
END IF;
|
|
50
|
-
END $$;
|
|
51
|
-
|
|
52
|
-
-- 4. PrizePayment: Rename bashCashTransactionId to bashPointsTransactionId
|
|
53
|
-
DO $$
|
|
54
|
-
BEGIN
|
|
55
|
-
IF EXISTS (
|
|
56
|
-
SELECT 1 FROM information_schema.columns
|
|
57
|
-
WHERE table_name = 'PrizePayment' AND column_name = 'bashCashTransactionId'
|
|
58
|
-
) THEN
|
|
59
|
-
ALTER TABLE "PrizePayment" RENAME COLUMN "bashCashTransactionId" TO "bashPointsTransactionId";
|
|
60
|
-
RAISE NOTICE '✅ Renamed PrizePayment.bashCashTransactionId → bashPointsTransactionId';
|
|
61
|
-
ELSE
|
|
62
|
-
RAISE NOTICE 'ℹ️ Column PrizePayment.bashCashTransactionId already renamed or does not exist';
|
|
63
|
-
END IF;
|
|
64
|
-
END $$;
|
|
65
|
-
|
|
66
|
-
-- 5. Service: Rename acceptsBashCash to acceptsBashPoints
|
|
67
|
-
DO $$
|
|
68
|
-
BEGIN
|
|
69
|
-
IF EXISTS (
|
|
70
|
-
SELECT 1 FROM information_schema.columns
|
|
71
|
-
WHERE table_name = 'Service' AND column_name = 'acceptsBashCash'
|
|
72
|
-
) THEN
|
|
73
|
-
ALTER TABLE "Service" RENAME COLUMN "acceptsBashCash" TO "acceptsBashPoints";
|
|
74
|
-
RAISE NOTICE '✅ Renamed Service.acceptsBashCash → acceptsBashPoints';
|
|
75
|
-
ELSE
|
|
76
|
-
RAISE NOTICE 'ℹ️ Column Service.acceptsBashCash already renamed or does not exist';
|
|
77
|
-
END IF;
|
|
78
|
-
END $$;
|
|
79
|
-
|
|
80
|
-
-- 6. ServiceBooking: Rename bashCashApplied to bashPointsApplied
|
|
81
|
-
DO $$
|
|
82
|
-
BEGIN
|
|
83
|
-
IF EXISTS (
|
|
84
|
-
SELECT 1 FROM information_schema.columns
|
|
85
|
-
WHERE table_name = 'ServiceBooking' AND column_name = 'bashCashApplied'
|
|
86
|
-
) THEN
|
|
87
|
-
ALTER TABLE "ServiceBooking" RENAME COLUMN "bashCashApplied" TO "bashPointsApplied";
|
|
88
|
-
RAISE NOTICE '✅ Renamed ServiceBooking.bashCashApplied → bashPointsApplied';
|
|
89
|
-
ELSE
|
|
90
|
-
RAISE NOTICE 'ℹ️ Column ServiceBooking.bashCashApplied already renamed or does not exist';
|
|
91
|
-
END IF;
|
|
92
|
-
END $$;
|
|
93
|
-
|
|
94
|
-
-- 7. ServiceBooking: Rename bashCashTransactionId to bashPointsTransactionId
|
|
95
|
-
DO $$
|
|
96
|
-
BEGIN
|
|
97
|
-
IF EXISTS (
|
|
98
|
-
SELECT 1 FROM information_schema.columns
|
|
99
|
-
WHERE table_name = 'ServiceBooking' AND column_name = 'bashCashTransactionId'
|
|
100
|
-
) THEN
|
|
101
|
-
ALTER TABLE "ServiceBooking" RENAME COLUMN "bashCashTransactionId" TO "bashPointsTransactionId";
|
|
102
|
-
RAISE NOTICE '✅ Renamed ServiceBooking.bashCashTransactionId → bashPointsTransactionId';
|
|
103
|
-
ELSE
|
|
104
|
-
RAISE NOTICE 'ℹ️ Column ServiceBooking.bashCashTransactionId already renamed or does not exist';
|
|
105
|
-
END IF;
|
|
106
|
-
END $$;
|
|
107
|
-
|
|
108
|
-
-- =====================================================================
|
|
109
|
-
-- SAFE ENUM VALUE UPDATES (Only updates if value exists)
|
|
110
|
-
-- =====================================================================
|
|
111
|
-
|
|
112
|
-
-- 8. Update AuditCategory enum: BashCash → BashPoints
|
|
113
|
-
DO $$
|
|
114
|
-
BEGIN
|
|
115
|
-
IF EXISTS (
|
|
116
|
-
SELECT 1 FROM pg_enum e
|
|
117
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
118
|
-
WHERE t.typname = 'AuditCategory' AND e.enumlabel = 'BashCash'
|
|
119
|
-
) THEN
|
|
120
|
-
ALTER TYPE "AuditCategory" RENAME VALUE 'BashCash' TO 'BashPoints';
|
|
121
|
-
RAISE NOTICE '✅ Renamed enum AuditCategory: BashCash → BashPoints';
|
|
122
|
-
ELSE
|
|
123
|
-
RAISE NOTICE 'ℹ️ Enum value AuditCategory.BashCash already renamed or does not exist';
|
|
124
|
-
END IF;
|
|
125
|
-
END $$;
|
|
126
|
-
|
|
127
|
-
-- 9. Update PrizePaymentMethod enum: BashCash → BashPoints
|
|
128
|
-
DO $$
|
|
129
|
-
BEGIN
|
|
130
|
-
IF EXISTS (
|
|
131
|
-
SELECT 1 FROM pg_enum e
|
|
132
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
133
|
-
WHERE t.typname = 'PrizePaymentMethod' AND e.enumlabel = 'BashCash'
|
|
134
|
-
) THEN
|
|
135
|
-
ALTER TYPE "PrizePaymentMethod" RENAME VALUE 'BashCash' TO 'BashPoints';
|
|
136
|
-
RAISE NOTICE '✅ Renamed enum PrizePaymentMethod: BashCash → BashPoints';
|
|
137
|
-
ELSE
|
|
138
|
-
RAISE NOTICE 'ℹ️ Enum value PrizePaymentMethod.BashCash already renamed or does not exist';
|
|
139
|
-
END IF;
|
|
140
|
-
END $$;
|
|
141
|
-
|
|
142
|
-
-- 10. Update AuditAction enum: BashCash → BashPoints
|
|
143
|
-
DO $$
|
|
144
|
-
BEGIN
|
|
145
|
-
IF EXISTS (
|
|
146
|
-
SELECT 1 FROM pg_enum e
|
|
147
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
148
|
-
WHERE t.typname = 'AuditAction' AND e.enumlabel = 'BashCash'
|
|
149
|
-
) THEN
|
|
150
|
-
ALTER TYPE "AuditAction" RENAME VALUE 'BashCash' TO 'BashPoints';
|
|
151
|
-
RAISE NOTICE '✅ Renamed enum AuditAction: BashCash → BashPoints';
|
|
152
|
-
ELSE
|
|
153
|
-
RAISE NOTICE 'ℹ️ Enum value AuditAction.BashCash already renamed or does not exist';
|
|
154
|
-
END IF;
|
|
155
|
-
END $$;
|
|
156
|
-
|
|
157
|
-
-- =====================================================================
|
|
158
|
-
-- VERIFICATION QUERIES (Runs automatically)
|
|
159
|
-
-- =====================================================================
|
|
160
|
-
|
|
161
|
-
-- Show renamed columns
|
|
162
|
-
SELECT
|
|
163
|
-
'✅ Columns with bashpoints naming:' AS info;
|
|
164
|
-
|
|
165
|
-
SELECT
|
|
166
|
-
table_name,
|
|
167
|
-
column_name,
|
|
168
|
-
data_type
|
|
169
|
-
FROM information_schema.columns
|
|
170
|
-
WHERE column_name ILIKE '%bashpoints%'
|
|
171
|
-
ORDER BY table_name, column_name;
|
|
172
|
-
|
|
173
|
-
-- Show enum values
|
|
174
|
-
SELECT
|
|
175
|
-
'✅ Enum values with BashPoints:' AS info;
|
|
176
|
-
|
|
177
|
-
SELECT
|
|
178
|
-
t.typname AS enum_type,
|
|
179
|
-
e.enumlabel AS enum_value
|
|
180
|
-
FROM pg_enum e
|
|
181
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
182
|
-
WHERE e.enumlabel ILIKE '%bashpoints%'
|
|
183
|
-
ORDER BY t.typname, e.enumlabel;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
-- Migration: Rename bashCredits* to bashPoints* (Complete BashPoints Migration)
|
|
2
|
-
-- Date: 2026-02-02
|
|
3
|
-
-- Description: Renames all remaining "bashCredits" columns to "bashPoints" to complete
|
|
4
|
-
-- the BashCash → BashPoints migration and maintain naming consistency
|
|
5
|
-
|
|
6
|
-
-- =====================================================================
|
|
7
|
-
-- DIAGNOSTIC: Check current state
|
|
8
|
-
-- =====================================================================
|
|
9
|
-
|
|
10
|
-
-- Check for bashCredits columns
|
|
11
|
-
SELECT
|
|
12
|
-
'📊 Current bashCredits columns:' AS info;
|
|
13
|
-
|
|
14
|
-
SELECT
|
|
15
|
-
table_name,
|
|
16
|
-
column_name,
|
|
17
|
-
data_type
|
|
18
|
-
FROM information_schema.columns
|
|
19
|
-
WHERE column_name ILIKE '%bashcredits%'
|
|
20
|
-
ORDER BY table_name, column_name;
|
|
21
|
-
|
|
22
|
-
-- =====================================================================
|
|
23
|
-
-- SAFE COLUMN RENAMES (Only renames if column exists)
|
|
24
|
-
-- =====================================================================
|
|
25
|
-
|
|
26
|
-
-- 1. User: Rename bashCreditsBalance to bashPointsBalance
|
|
27
|
-
DO $$
|
|
28
|
-
BEGIN
|
|
29
|
-
IF EXISTS (
|
|
30
|
-
SELECT 1 FROM information_schema.columns
|
|
31
|
-
WHERE table_name = 'User' AND column_name = 'bashCreditsBalance'
|
|
32
|
-
) THEN
|
|
33
|
-
ALTER TABLE "User" RENAME COLUMN "bashCreditsBalance" TO "bashPointsBalance";
|
|
34
|
-
RAISE NOTICE '✅ Renamed User.bashCreditsBalance → bashPointsBalance';
|
|
35
|
-
ELSE
|
|
36
|
-
RAISE NOTICE 'ℹ️ Column User.bashCreditsBalance already renamed or does not exist';
|
|
37
|
-
END IF;
|
|
38
|
-
END $$;
|
|
39
|
-
|
|
40
|
-
-- 2. User: Rename bashCreditsEarnedLifetime to bashPointsEarnedLifetime
|
|
41
|
-
DO $$
|
|
42
|
-
BEGIN
|
|
43
|
-
IF EXISTS (
|
|
44
|
-
SELECT 1 FROM information_schema.columns
|
|
45
|
-
WHERE table_name = 'User' AND column_name = 'bashCreditsEarnedLifetime'
|
|
46
|
-
) THEN
|
|
47
|
-
ALTER TABLE "User" RENAME COLUMN "bashCreditsEarnedLifetime" TO "bashPointsEarnedLifetime";
|
|
48
|
-
RAISE NOTICE '✅ Renamed User.bashCreditsEarnedLifetime → bashPointsEarnedLifetime';
|
|
49
|
-
ELSE
|
|
50
|
-
RAISE NOTICE 'ℹ️ Column User.bashCreditsEarnedLifetime already renamed or does not exist';
|
|
51
|
-
END IF;
|
|
52
|
-
END $$;
|
|
53
|
-
|
|
54
|
-
-- 3. User: Rename bashCreditsSpentLifetime to bashPointsSpentLifetime
|
|
55
|
-
DO $$
|
|
56
|
-
BEGIN
|
|
57
|
-
IF EXISTS (
|
|
58
|
-
SELECT 1 FROM information_schema.columns
|
|
59
|
-
WHERE table_name = 'User' AND column_name = 'bashCreditsSpentLifetime'
|
|
60
|
-
) THEN
|
|
61
|
-
ALTER TABLE "User" RENAME COLUMN "bashCreditsSpentLifetime" TO "bashPointsSpentLifetime";
|
|
62
|
-
RAISE NOTICE '✅ Renamed User.bashCreditsSpentLifetime → bashPointsSpentLifetime';
|
|
63
|
-
ELSE
|
|
64
|
-
RAISE NOTICE 'ℹ️ Column User.bashCreditsSpentLifetime already renamed or does not exist';
|
|
65
|
-
END IF;
|
|
66
|
-
END $$;
|
|
67
|
-
|
|
68
|
-
-- =====================================================================
|
|
69
|
-
-- VERIFICATION: Show final state
|
|
70
|
-
-- =====================================================================
|
|
71
|
-
|
|
72
|
-
-- Show all bashPoints columns
|
|
73
|
-
SELECT
|
|
74
|
-
'✅ Final bashPoints columns:' AS info;
|
|
75
|
-
|
|
76
|
-
SELECT
|
|
77
|
-
table_name,
|
|
78
|
-
column_name,
|
|
79
|
-
data_type,
|
|
80
|
-
is_nullable,
|
|
81
|
-
column_default
|
|
82
|
-
FROM information_schema.columns
|
|
83
|
-
WHERE column_name ILIKE '%bashpoints%'
|
|
84
|
-
ORDER BY table_name, column_name;
|
|
85
|
-
|
|
86
|
-
-- Verify no bashCredits columns remain
|
|
87
|
-
SELECT
|
|
88
|
-
'🔍 Checking for remaining bashCredits columns (should be empty):' AS info;
|
|
89
|
-
|
|
90
|
-
SELECT
|
|
91
|
-
table_name,
|
|
92
|
-
column_name,
|
|
93
|
-
data_type
|
|
94
|
-
FROM information_schema.columns
|
|
95
|
-
WHERE column_name ILIKE '%bashcredits%'
|
|
96
|
-
ORDER BY table_name, column_name;
|