Fix migrations.

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu 2025-10-20 01:20:28 +03:00
parent e61f6b1c89
commit 0acbf30b03
2 changed files with 61 additions and 0 deletions

View file

@ -369,6 +369,24 @@ class CronJobStorage {
completedSteps: jobSteps.filter(step => step.status === 'completed').length
};
}
/**
* Clear all jobs from storage
*/
clearAllJobs() {
try {
// Clear all collections
CronJobStatus.remove({});
CronJobSteps.remove({});
CronJobQueue.remove({});
console.log('All cron job data cleared from storage');
return { success: true, message: 'All cron job data cleared' };
} catch (error) {
console.error('Error clearing cron job storage:', error);
return { success: false, error: error.message };
}
}
}
// Export singleton instance

View file

@ -1308,6 +1308,41 @@ class CronMigrationManager {
return stats;
}
/**
* Clear all cron jobs and restart migration system
*/
clearAllCronJobs() {
try {
// Stop all existing cron jobs
if (SyncedCron && SyncedCron.jobs) {
SyncedCron.jobs.forEach(job => {
try {
SyncedCron.remove(job.name);
} catch (error) {
console.warn(`Failed to remove cron job ${job.name}:`, error.message);
}
});
}
// Clear job storage
cronJobStorage.clearAllJobs();
// Reset migration steps
this.migrationSteps = this.initializeMigrationSteps();
this.currentStepIndex = 0;
this.isRunning = false;
// Restart the migration system
this.initialize();
console.log('All cron jobs cleared and migration system restarted');
return { success: true, message: 'All cron jobs cleared and migration system restarted' };
} catch (error) {
console.error('Error clearing cron jobs:', error);
return { success: false, error: error.message };
}
}
}
// Export singleton instance
@ -1446,6 +1481,14 @@ Meteor.methods({
return cronJobStorage.getSystemResources();
},
'cron.clearAllJobs'() {
if (!this.userId) {
throw new Meteor.Error('not-authorized');
}
return cronMigrationManager.clearAllCronJobs();
},
'cron.pauseJob'(jobId) {
if (!this.userId) {
throw new Meteor.Error('not-authorized');