Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

niclm's avatar
Level 9

Kernel Command Breaks Fresh Deployment

Hey Guys,

I have scheduled a command to do some processing at a time which is configured in a database table.

The problem I have found is that with a fresh install, php artisan migrate:fresh (or any artisan command) fails to say it cant find the table, how do I skip this command when doing my initial deployment ? Or is there a better place for this command ?

$schedule->command('foo:bar')->dailyAt(Setting::find('foo_deadline')->value);

Error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'foo.settings' doesn't exist
0 likes
3 replies
niclm's avatar
Level 9

Would this be an acceptable solution:

if(Schema::hasTable('settings')){
   $schedule->command('foo:bar')->dailyAt(......
}
Snapey's avatar

you should put this code in the cron scheduler, otherwise you are running the task on every http request to your site

niclm's avatar
Level 9

Sorry I should have mentioned its in the console kernel so that it runs with cron

Please or to participate in this conversation.