Skip to content

Commit 1208f24

Browse files
author
Ronald A Richardson
committed
feat: schedule sandbox:sync to run hourly
Registers the sandbox:sync Artisan command in the CoreServiceProvider scheduler so that production users and companies are periodically mirrored into the sandbox database without any manual intervention. Hourly cadence is chosen as a sensible default: - New users/companies created in production become available in sandbox within at most one hour, keeping the sandbox reasonably fresh. - The command is lightweight (upserts only; no heavy data transforms) so running it every hour does not impose meaningful DB load. - withoutOverlapping() ensures a long-running sync cannot queue up multiple concurrent instances if the scheduler fires while a previous run is still in progress. This complements the on-demand sync added to ApiCredentialController (which handles the immediate FK-constraint case at key-creation time) by ensuring the sandbox stays broadly consistent with production over time for all other sandbox operations.
1 parent e19c142 commit 1208f24

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/Providers/CoreServiceProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ public function boot()
165165
$schedule->command('purge:scheduled-task-logs --force --no-interaction --days 1')->twiceDaily(1, 13);
166166
$schedule->command('telemetry:ping')->daily();
167167
$schedule->job(new \Fleetbase\Jobs\MaterializeSchedulesJob())->dailyAt('01:00')->name('materialize-schedules')->withoutOverlapping();
168+
// Keep sandbox users/companies in sync with production so that
169+
// test-mode API key creation (and other sandbox operations) never
170+
// fail due to missing foreign-key referenced rows. Hourly cadence
171+
// is a good balance: frequent enough that new users/companies are
172+
// available in sandbox within an hour of being created in
173+
// production, but infrequent enough to avoid unnecessary DB load.
174+
$schedule->command('sandbox:sync')->hourly()->name('sandbox-sync')->withoutOverlapping();
168175
});
169176
$this->registerObservers();
170177
$this->registerExpansionsFrom();

0 commit comments

Comments
 (0)