From f44a8216bf810105e3054220f2e56c4a26e7df33 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Wed, 29 Apr 2026 16:26:35 +0800 Subject: [PATCH] fix: jalankan prisma migrate deploy otomatis jika ada pending migrations Sebelumnya pipeline dibatalkan saat ada pending migrations. Sekarang langsung deploy migrations lalu lanjut ke step berikutnya. Co-Authored-By: Claude Sonnet 4.6 --- scripts/mcp-deploy.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/mcp-deploy.ts b/scripts/mcp-deploy.ts index 09fb210..5b9c4f0 100644 --- a/scripts/mcp-deploy.ts +++ b/scripts/mcp-deploy.ts @@ -112,23 +112,27 @@ server.tool( async ({ tag }) => { const log: string[] = [] - // ── 1. Cek migrasi ────────────────────────────────────────────────────── - const migrate = await sh(['bunx', 'prisma', 'migrate', 'status']) - if (!migrate.ok || migrate.out.includes('not yet been applied')) { - return { - content: [{ - type: 'text', - text: [ - '❌ Deploy dibatalkan — ada pending migrations.', - '', - migrate.out || migrate.err, - '', - 'Jalankan `bun run db:migrate` terlebih dahulu.', - ].join('\n'), - }], + // ── 1. Cek & jalankan migrasi jika ada ───────────────────────────────── + const migrateStatus = await sh(['bunx', 'prisma', 'migrate', 'status']) + if (!migrateStatus.ok || migrateStatus.out.includes('not yet been applied')) { + log.push('⏳ Ada pending migrations — menjalankan migrate deploy...') + const migrateRun = await sh(['bunx', 'prisma', 'migrate', 'deploy']) + if (!migrateRun.ok) { + return { + content: [{ + type: 'text', + text: [ + ...log, + '❌ Migrate deploy gagal:', + migrateRun.err || migrateRun.out, + ].join('\n'), + }], + } } + log.push('✅ Migrations: deployed') + } else { + log.push('✅ Migrations: up to date') } - log.push('✅ Migrations: up to date') // ── 2. Version bump ────────────────────────────────────────────────────── const pkgPath = `${process.cwd()}/package.json`