当前位置: 动力学知识库 > 问答 > 编程问答 >

How to get resultant mysql instructions from php artisan migrate

问题描述:

I was wondering if there's a way to get the resultant mysql instructions from the command php artisan migrate.

This is needed because on my production server I can run mysql commands from PhpMyAdmin but I'm not allowed to run terminal scripts.

So my idea was to run php artisan migrate on my local environment and get the resultant mysql instructions to import "by hand" on production.

网友答案:

You can call Artisan from code as @maximl337 mentioned but in case you want to look only show SQL that will be executed (without running it), you can use --pretend option this way:

php artisan migrate --pretend

and you will get this way the whole SQL that would be executed running migrations.

网友答案:

Try calling Artisan command via code:

Route::get('/migrate', function () {
    Artisan::call('migrate', [
        '--force' => true,
    ]);
})->middleware(['admin']);

https://laravel.com/docs/5.1/artisan#calling-commands-via-code

分享给朋友:
您可能感兴趣的文章:
随机阅读: