mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Fix migrations.
Thanks to xet7 !
This commit is contained in:
parent
e61f6b1c89
commit
0acbf30b03
2 changed files with 61 additions and 0 deletions
|
|
@ -369,6 +369,24 @@ class CronJobStorage {
|
||||||
completedSteps: jobSteps.filter(step => step.status === 'completed').length
|
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
|
// Export singleton instance
|
||||||
|
|
|
||||||
|
|
@ -1308,6 +1308,41 @@ class CronMigrationManager {
|
||||||
return stats;
|
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
|
// Export singleton instance
|
||||||
|
|
@ -1446,6 +1481,14 @@ Meteor.methods({
|
||||||
return cronJobStorage.getSystemResources();
|
return cronJobStorage.getSystemResources();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'cron.clearAllJobs'() {
|
||||||
|
if (!this.userId) {
|
||||||
|
throw new Meteor.Error('not-authorized');
|
||||||
|
}
|
||||||
|
|
||||||
|
return cronMigrationManager.clearAllCronJobs();
|
||||||
|
},
|
||||||
|
|
||||||
'cron.pauseJob'(jobId) {
|
'cron.pauseJob'(jobId) {
|
||||||
if (!this.userId) {
|
if (!this.userId) {
|
||||||
throw new Meteor.Error('not-authorized');
|
throw new Meteor.Error('not-authorized');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue