Cavalcade icon indicating copy to clipboard operation
Cavalcade copied to clipboard

Migration

Open Rahe opened this issue 8 years ago • 4 comments

Hello,

My question is about current big installions that will migrate to WP native cron to Calvalcade cron system. Is it possible ? I think we can

  1. remove filters of Calvacade
  2. get the events schedules
  3. re-add the filters
  4. reschedule everything through the WordPress API

but is it safe ?

Regards,

Rahe avatar May 30 '17 14:05 Rahe

@Rahe , what was your solution for migrating existing cron tasks to Cavalcade?

discoinfiltrator avatar Apr 26 '18 20:04 discoinfiltrator

Hello @discoinfiltrator ,

the process described on my main message, and run it site by site

Rahe avatar Jun 01 '18 10:06 Rahe

So Cavalcade doesn't include a migration of old cron events to Cavalcade tables? Really?

archon810 avatar Mar 04 '20 19:03 archon810

@archon810 , this is a script that my company ran a couple years back to migrate our data:

remove_filter('pre_option_cron', 'HM\Cavalcade\Plugin\Connector\get_cron_array');
remove_filter('pre_update_option_cron', 'HM\Cavalcade\Plugin\Connector\update_cron_array', 10);

$crons = _get_cron_array();

$timestamp = time();
$crons['version'] = 2;
add_option('cron_' . $timestamp, $crons);
unset($crons['version']);

_set_cron_array([]);

add_filter('pre_option_cron', 'HM\Cavalcade\Plugin\Connector\get_cron_array');
add_filter('pre_update_option_cron', 'HM\Cavalcade\Plugin\Connector\update_cron_array', 10, 2);

$count = 0;
foreach ($crons as $timestamp => $cronhooks) {
    foreach ($cronhooks as $hook => $keys) {
        foreach ($keys as $k => $v) {
            if ($v['schedule'] == '' && !isset($v['interval'])) {
                $result = wp_schedule_single_event($timestamp, $hook, $v['args']);
                if ($result !== false) {
                    $count++;
                }
            }
        }
    }
}

Definitely test it out first - I haven't ran it in some time but I believe it went fine. We only migrated the single events that were previously scheduled as any recurring events would re-schedule themselves.

I can't recall exactly but I think the add_option call was just to save a backup.

discoinfiltrator avatar Mar 04 '20 19:03 discoinfiltrator