Upgrading

This page summarizes the breaking changes between major versions of laravel-schedule-monitor, based on the repository's UPGRADING.md and changelog, with the concrete steps for each upgrade. For every release's details, see the changelog on GitHub.

Version Overview

Version Laravel PHP Notable
4.3.x 11, 12, 13 8.2+ Debug logging, configurable retry delay, OhDearPingFailed event; Laravel 9/10 and PHP 8.1 dropped in 4.3.0
4.2.0 adds 13
4.1.0 Configurable ping job (ping_oh_dear_job)
4.0.0 Built-in Oh Dear client, "sites" renamed to "monitors"
3.x CleanCommand replaced by model pruning
2.x 8 Last line supporting Laravel 8

From v3 to v4

The Oh Dear integration was simplified, and Oh Dear renamed "sites" to "monitors".

  1. The Oh Dear SDK is no longer needed. The package now calls the Oh Dear API with Laravel's HTTP client. You can remove the separate SDK package from your composer.json if nothing else in your application uses it.
  2. Replace site_id with monitor_id in the oh_dear section of config/schedule-monitor.php:

    /*
     *  The id of the monitor you want to sync the schedule with.
     *
     * You'll find this id on the settings page of a monitor at Oh Dear.
     */
    'monitor_id' => env('OH_DEAR_MONITOR_ID'),
  3. Rename the environment variable OH_DEAR_SITE_ID to OH_DEAR_MONITOR_ID in your .env files and deployment secrets.

  4. Run php artisan schedule-monitor:verify, then php artisan schedule-monitor:sync.

Warning: If you forget step 2 or 3, monitor_id is empty: the sync then silently skips Oh Dear (only a yellow notice is printed), while tasks keep pinging the ping URLs stored by earlier syncs.

New in the 4.x line, all optional (add the keys to your published config to change them, see Configuration):

Key Since Purpose
oh_dear.api_url 3.10.3 Oh Dear API base URL
oh_dear.endpoint_url 3.10.0 Custom ping endpoint
oh_dear.ping_oh_dear_job 4.1.0 Custom ping job class
oh_dear.retry_delay_ms 4.3.0 Delay between HTTP tries
oh_dear.debug_logging 4.3.0 Diagnostics for failed pings

From v2 to v3

The CleanCommand that deleted old log items was removed. Use Laravel's model pruning instead:

// routes/console.php (or the schedule() method of app/Console/Kernel.php)
use Illuminate\Support\Facades\Schedule;
use Spatie\ScheduleMonitor\Models\MonitoredScheduledTaskLogItem;

Schedule::command('model:prune', ['--model' => MonitoredScheduledTaskLogItem::class])->daily();

Remove the old clean command from your schedule. The retention period is still delete_log_items_older_than_days. See Prune Old Log Items.

From v1 to v2

Add a nullable string column timezone to the monitored_scheduled_tasks table, and fill it in existing rows with your application's timezone:

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('monitored_scheduled_tasks', function (Blueprint $table) {
            $table->string('timezone')->nullable();
        });

        DB::table('monitored_scheduled_tasks')->update(['timezone' => config('app.timezone')]);
    }
};

Running schedule-monitor:sync afterwards also sets the timezone of every task still in the schedule.

After Any Upgrade

  1. Compare your published config/schedule-monitor.php with the package's current file and add new keys you want to use.
  2. Run php artisan schedule-monitor:sync so the database and Oh Dear reflect the current code.
  3. Run php artisan schedule-monitor:list and check for unnamed or duplicate tasks.

See Also