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 }) => {
|
async ({ tag }) => {
|
||||||
const log: string[] = []
|
const log: string[] = []
|
||||||
|
|
||||||
// ── 1. Cek migrasi ──────────────────────────────────────────────────────
|
// ── 1. Cek & jalankan migrasi jika ada ─────────────────────────────────
|
||||||
const migrate = await sh(['bunx', 'prisma', 'migrate', 'status'])
|
const migrateStatus = await sh(['bunx', 'prisma', 'migrate', 'status'])
|
||||||
if (!migrate.ok || migrate.out.includes('not yet been applied')) {
|
if (!migrateStatus.ok || migrateStatus.out.includes('not yet been applied')) {
|
||||||
return {
|
log.push('⏳ Ada pending migrations — menjalankan migrate deploy...')
|
||||||
content: [{
|
const migrateRun = await sh(['bunx', 'prisma', 'migrate', 'deploy'])
|
||||||
type: 'text',
|
if (!migrateRun.ok) {
|
||||||
text: [
|
return {
|
||||||
'❌ Deploy dibatalkan — ada pending migrations.',
|
content: [{
|
||||||
'',
|
type: 'text',
|
||||||
migrate.out || migrate.err,
|
text: [
|
||||||
'',
|
...log,
|
||||||
'Jalankan `bun run db:migrate` terlebih dahulu.',
|
'❌ Migrate deploy gagal:',
|
||||||
].join('\n'),
|
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 ──────────────────────────────────────────────────────
|
// ── 2. Version bump ──────────────────────────────────────────────────────
|
||||||
const pkgPath = `${process.cwd()}/package.json`
|
const pkgPath = `${process.cwd()}/package.json`
|
||||||
|
|||||||
Reference in New Issue
Block a user