fix(sqlite): take a single database backup per upgrade instead of one per migration

This commit is contained in:
Tyagiquamar
2026-09-17 22:45:42 +05:30
parent b0e2fcadd4
commit 803fbb2ea2
2 changed files with 159 additions and 5 deletions
+8 -5
View File
@@ -191,15 +191,18 @@ async function executeScripts() {
);
// Run migrations in order
// Take a single backup before any migration runs, so one upgrade
// produces one restore point instead of one backup per migration.
if (
migrationsToRun.length > 0 &&
!process.env.DISABLE_BACKUP_ON_MIGRATION
) {
backupDb();
}
for (const migration of migrationsToRun) {
console.log(`Running migration ${migration.version}`);
try {
if (!process.env.DISABLE_BACKUP_ON_MIGRATION) {
// Backup the database before running the migration
backupDb();
}
await migration.run();
// Update version in database