From 5b0f98264ccf69e56f61cf5b1919d17224fc30d9 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Thu, 6 Aug 2026 15:17:20 +0800 Subject: [PATCH] fix(deploy): align intake sku schema before release --- .../migration.sql | 8 +++++ .../scripts/verify-prisma-runtime-schema.js | 33 +++++++++++++++++++ scripts/deploy-yydd-prod-from-git.ps1 | 4 +++ 3 files changed, 45 insertions(+) create mode 100644 furniture-3d-system/prisma/migrations/20260806143000_add_intake_sku_source_fields/migration.sql create mode 100644 furniture-3d-system/scripts/verify-prisma-runtime-schema.js diff --git a/furniture-3d-system/prisma/migrations/20260806143000_add_intake_sku_source_fields/migration.sql b/furniture-3d-system/prisma/migrations/20260806143000_add_intake_sku_source_fields/migration.sql new file mode 100644 index 00000000..a33ed6f1 --- /dev/null +++ b/furniture-3d-system/prisma/migrations/20260806143000_add_intake_sku_source_fields/migration.sql @@ -0,0 +1,8 @@ +-- Keep the structured SKU table aligned with the source metadata fields in +-- IntakeNonIntegratedSkuItem. Historical SKU payloads do not carry values for +-- these fields, so no data backfill is required. +ALTER TABLE "IntakeNonIntegratedSkuItem" + ADD COLUMN IF NOT EXISTS "sourceWeight" DECIMAL(18, 3), + ADD COLUMN IF NOT EXISTS "sourceBrand" TEXT NOT NULL DEFAULT '', + ADD COLUMN IF NOT EXISTS "sourceCreatedAt" TIMESTAMP(3), + ADD COLUMN IF NOT EXISTS "sourceUpdatedAt" TIMESTAMP(3); diff --git a/furniture-3d-system/scripts/verify-prisma-runtime-schema.js b/furniture-3d-system/scripts/verify-prisma-runtime-schema.js new file mode 100644 index 00000000..c21848b1 --- /dev/null +++ b/furniture-3d-system/scripts/verify-prisma-runtime-schema.js @@ -0,0 +1,33 @@ +const { PrismaClient } = require('@prisma/client') +const { PrismaPg } = require('@prisma/adapter-pg') +const { Pool } = require('pg') + +const databaseUrl = process.env.DATABASE_URL + +if (!databaseUrl) { + throw new Error('DATABASE_URL is required for the Prisma runtime schema check.') +} + +const pool = new Pool({ connectionString: databaseUrl }) +const prisma = new PrismaClient({ adapter: new PrismaPg(pool) }) + +async function main() { + // Select the complete model so missing scalar columns fail before release. + await prisma.intakeNonIntegratedSkuItem.findFirst({ + orderBy: { createdAt: 'desc' }, + }) + + console.log('Prisma runtime schema check passed for IntakeNonIntegratedSkuItem.') +} + +main() + .catch((error) => { + const code = typeof error?.code === 'string' ? error.code : 'unknown' + console.error(`Prisma runtime schema check failed (${code}).`) + console.error(error) + process.exitCode = 1 + }) + .finally(async () => { + await prisma.$disconnect() + await pool.end() + }) diff --git a/scripts/deploy-yydd-prod-from-git.ps1 b/scripts/deploy-yydd-prod-from-git.ps1 index d61f58bb..8a60209a 100644 --- a/scripts/deploy-yydd-prod-from-git.ps1 +++ b/scripts/deploy-yydd-prod-from-git.ps1 @@ -573,6 +573,10 @@ export ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm ci --no-audit --no-fund npx prisma generate npx prisma migrate deploy +set -a +source "$SHARED/.env" +set +a +node scripts/verify-prisma-runtime-schema.js npm run build ensure_shared_non_integrated_assets "$APP_DIR"