mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
chore(server): auto roll back failed migrations (#12697)
This commit is contained in:
@@ -47,5 +47,33 @@ function runPredeployScript() {
|
||||
});
|
||||
}
|
||||
|
||||
function fixFailedMigrations() {
|
||||
console.log('fixing failed migrations.');
|
||||
const maybeFailedMigrations = [
|
||||
'20250521083048_fix_workspace_embedding_chunk_primary_key',
|
||||
];
|
||||
for (const migration of maybeFailedMigrations) {
|
||||
try {
|
||||
execSync(`yarn prisma migrate resolve --rolled-back ${migration}`, {
|
||||
encoding: 'utf-8',
|
||||
env: process.env,
|
||||
stdio: 'pipe',
|
||||
});
|
||||
console.log(`migration [${migration}] has been rolled back.`);
|
||||
} catch (err) {
|
||||
if (
|
||||
err.message.includes(
|
||||
'cannot be rolled back because it is not in a failed state'
|
||||
)
|
||||
) {
|
||||
// migration has been rolled back, skip it
|
||||
continue;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prepare();
|
||||
fixFailedMigrations();
|
||||
runPredeployScript();
|
||||
|
||||
Reference in New Issue
Block a user