@bash-app/bash-common 30.118.0 → 30.119.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/definitions.d.ts +3 -0
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/membershipDefinitions.d.ts +9 -5
- package/dist/membershipDefinitions.d.ts.map +1 -1
- package/dist/membershipDefinitions.js +28 -24
- package/dist/membershipDefinitions.js.map +1 -1
- package/dist/utils/bashPointsPaymentUtils.d.ts +55 -0
- package/dist/utils/bashPointsPaymentUtils.d.ts.map +1 -0
- package/dist/utils/bashPointsPaymentUtils.js +79 -0
- package/dist/utils/bashPointsPaymentUtils.js.map +1 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/ticketListUtils.d.ts +2 -1
- package/dist/utils/ticketListUtils.d.ts.map +1 -1
- package/dist/utils/ticketListUtils.js +61 -11
- package/dist/utils/ticketListUtils.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/add_bashcash_pricing_to_ticket_tier.sql +15 -0
- package/prisma/migrations/add_bashpoints_purchase_tracking.sql +33 -0
- package/prisma/migrations/add_pricing_type_enum.sql +88 -0
- package/prisma/migrations/diagnostic_bashcash_columns.sql +157 -0
- package/prisma/migrations/fix_bashcash_referral_code_schema_mismatch.sql +81 -0
- package/prisma/migrations/rename_bashcash_to_bashpoints.sql +183 -0
- package/prisma/migrations/rename_bashcredits_to_bashpoints.sql +96 -0
- package/prisma/schema.prisma +432 -317
- package/src/definitions.ts +3 -0
- package/src/index.ts +1 -1
- package/src/membershipDefinitions.ts +29 -25
- package/src/utils/bashPointsPaymentUtils.ts +107 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/ticketListUtils.ts +64 -10
- package/src/utils/bashCashPaymentUtils.ts +0 -146
|
@@ -0,0 +1,183 @@
|
|
|
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;
|
|
@@ -0,0 +1,96 @@
|
|
|
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;
|