33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
// Mark the failed drop_flash_sale migration as rolled_back so deploy can retry.
|
|
const { PrismaClient } = require('@prisma/client')
|
|
const p = new PrismaClient()
|
|
const dump = (x) => JSON.stringify(x, (_, v) => typeof v === 'bigint' ? v.toString() : v, 2)
|
|
;(async () => {
|
|
const before = await p.$queryRawUnsafe(
|
|
`SELECT migration_name, finished_at, rolled_back_at, applied_steps_count
|
|
FROM _prisma_migrations
|
|
WHERE migration_name = ?`,
|
|
'20260910030338_drop_flash_sale'
|
|
)
|
|
console.log('before:', dump(before))
|
|
|
|
const result = await p.$executeRawUnsafe(
|
|
`UPDATE _prisma_migrations
|
|
SET rolled_back_at = NOW()
|
|
WHERE migration_name = ?
|
|
AND finished_at IS NULL
|
|
AND rolled_back_at IS NULL`,
|
|
'20260910030338_drop_flash_sale'
|
|
)
|
|
console.log('rows updated:', result)
|
|
|
|
const after = await p.$queryRawUnsafe(
|
|
`SELECT migration_name, finished_at, rolled_back_at, applied_steps_count
|
|
FROM _prisma_migrations
|
|
WHERE migration_name = ?`,
|
|
'20260910030338_drop_flash_sale'
|
|
)
|
|
console.log('after:', dump(after))
|
|
|
|
await p.$disconnect()
|
|
})().catch((e) => { console.error(e); process.exit(1) }) |