fix migration production
Build & Push / Pipeline Tests (push) Successful in 1m56s
Test / Type Check (all packages) (push) Successful in 55s
Build & Push / Build & Push Docker Image (push) Successful in 3m34s
Test / API Unit Tests (push) Successful in 1m12s
Test / Homepage Unit Tests (push) Successful in 49s
Test / Carplace Unit Tests (push) Successful in 41s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Successful in 45s
Test / API Integration Tests (push) Successful in 1m6s

This commit is contained in:
root
2026-08-17 21:59:23 -04:00
parent 5f1c427600
commit 72671d146d
2 changed files with 12 additions and 11 deletions
@@ -26,10 +26,13 @@ BEGIN
AND column_name = 'paymentMethodsEnabled' AND column_name = 'paymentMethodsEnabled'
) THEN ) THEN
UPDATE "brand_settings" UPDATE "brand_settings"
SET "paymentMethodsEnabled" = ARRAY( SET "paymentMethodsEnabled" = COALESCE(
SELECT x ARRAY(
FROM unnest("paymentMethodsEnabled") AS x SELECT x
WHERE x::text <> 'STRIPE' FROM unnest("paymentMethodsEnabled") AS x
WHERE x::text <> 'STRIPE'
),
ARRAY[]::"PaymentProvider"[]
) )
WHERE EXISTS ( WHERE EXISTS (
SELECT 1 SELECT 1
@@ -107,15 +110,13 @@ BEGIN
AND table_name = 'brand_settings' AND table_name = 'brand_settings'
AND column_name = 'paymentMethodsEnabled' AND column_name = 'paymentMethodsEnabled'
) THEN ) THEN
-- PostgreSQL rejects subqueries in ALTER ... USING. STRIPE was already
-- filtered out above, so a text-array recast is enough.
ALTER TABLE "brand_settings" ALTER TABLE "brand_settings"
ALTER COLUMN "paymentMethodsEnabled" TYPE "PaymentProvider_new"[] ALTER COLUMN "paymentMethodsEnabled" TYPE "PaymentProvider_new"[]
USING ( USING (
COALESCE( COALESCE(
ARRAY( "paymentMethodsEnabled"::text[]::"PaymentProvider_new"[],
SELECT x::text::"PaymentProvider_new"
FROM unnest("paymentMethodsEnabled") AS x
WHERE x::text <> 'STRIPE'
),
ARRAY[]::"PaymentProvider_new"[] ARRAY[]::"PaymentProvider_new"[]
) )
); );
+2 -2
View File
@@ -155,8 +155,8 @@ async function main() {
} }
// Prisma records a failed transactional migration even after the SQL rolls back. // Prisma records a failed transactional migration even after the SQL rolls back.
// In local/dev Docker that leftover row blocks every subsequent startup. // That leftover row blocks every subsequent Docker/startup deploy.
if (process.env.NODE_ENV === 'production') { if (process.env.DB_DEPLOY_SKIP_FAILED_RETRY === 'true') {
console.error('[db:deploy] Found failed migrations in a non-empty database. Resolve them manually before deploying again.') console.error('[db:deploy] Found failed migrations in a non-empty database. Resolve them manually before deploying again.')
process.exit(1) process.exit(1)
} }