Skip to content

Commit

Permalink
improve schedule seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
recursivetree committed Mar 24, 2024
1 parent 3ab32b5 commit 9dcf351
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions src/database/seeders/ScheduleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,40 @@

namespace Seat\Web\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Seat\Services\Seeding\AbstractScheduleSeeder;

/**
* Class ScheduleSeeder.
*
* @package Seat\Web\database\seeds
*/
class ScheduleSeeder extends Seeder
class ScheduleSeeder extends AbstractScheduleSeeder
{
/**
* @var array
* Returns an array of schedules that should be seeded whenever the stack boots up
*
* @return array
*/
protected $schedules = [
[ // Horizon Metrics | Every Five Minutes
'command' => 'horizon:snapshot',
'expression' => '*/5 * * * *',
'allow_overlap' => false,
'allow_maintenance' => false,
'ping_before' => null,
'ping_after' => null,
],
];
function getSchedules(): array
{
return [
[ // Horizon Metrics | Every Five Minutes
'command' => 'horizon:snapshot',
'expression' => '*/5 * * * *',
'allow_overlap' => false,
'allow_maintenance' => false,
'ping_before' => null,
'ping_after' => null,
],
];
}

/**
* Run the database seeds.
*
* @return void
* Returns a list of commands to remove from the schedule
* @return array
*/
public function run()
function getDeprecatedSchedules(): array
{
// Check if we have the schedules, else,
// insert them
foreach ($this->schedules as $job) {
if (DB::table('schedules')->where('command', $job['command'])->exists()) {
DB::table('schedules')->where('command', $job['command'])->update([
'expression' => $job['expression'],
]);
} else {
DB::table('schedules')->insert($job);
}
}
return [];
}
}

0 comments on commit 9dcf351

Please sign in to comment.