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 <noreply@anthropic.com>
This commit is contained in:
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user