Artisan::call('migrate:fresh') on php script making the site unavailable for the first time and works on next reload

232 Views Asked by At

I am using the below method

private function migrate(BufferedOutput $outputLog)
{
    try {
            Artisan::call('migrate:fresh', $outputLog);
        } catch (Exception $e) {
            return $this->response($e->getMessage(), 'error', $outputLog);
        }

    return $this->seed($outputLog);
}

But for the first time (redirecting on PHP script to /install/database), the page does not appear, on refresh, it works as expected.

and the error is enter image description here

1

There are 1 best solutions below

0
Sujith Sandeep On

As far as I have seen your issue might be, If you use "migrate:fresh", All the tables will be dropped and up methods will run which creates the fresh tables. This process will take some time. So, For the first time you reload the website, The migration will be running. Since the migration is in process, You will be getting "The site can't be reached" error.

To fix this, make sure to place a page displaying "Site is under development" till the migration completes. Then everything will work fine. But doing this kind of things are not suggestable.