mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-23 02:52:58 +02:00
fix(sqlite): take a single database backup per upgrade instead of one per migration
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user