diff --git a/server/cronMigrationManager.js b/server/cronMigrationManager.js index c509a396a..9b0b7faab 100644 --- a/server/cronMigrationManager.js +++ b/server/cronMigrationManager.js @@ -645,6 +645,11 @@ class CronMigrationManager { */ async runMigrationStep(step) { try { + // Check if already completed + if (step.completed) { + return; // Skip if already completed + } + // Starting migration step cronMigrationCurrentStep.set(step.name); @@ -666,6 +671,9 @@ class CronMigrationManager { step.progress = 100; step.status = 'completed'; + // Remove the cron job to prevent re-running every minute + SyncedCron.remove(step.cronName); + // Completed migration step // Update progress @@ -692,6 +700,15 @@ class CronMigrationManager { this.startTime = Date.now(); try { + // Remove cron jobs to prevent conflicts with job queue + this.migrationSteps.forEach(step => { + try { + SyncedCron.remove(step.cronName); + } catch (error) { + // Ignore errors if cron job doesn't exist + } + }); + // Add all migration steps to the job queue for (let i = 0; i < this.migrationSteps.length; i++) { const step = this.migrationSteps[i];