16
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel5でmigrate実行時に「Application In Production!」とconfirmが出るのをなくす

Posted at

Laravel5にてproduction環境にて以下を実行するとconfirmが出る

$ php artisan migrate
**************************************
*     Application In Production!     *
**************************************

Do you really wish to run this command? [y/N]

デプロイツールなどで実行するときに邪魔なのでなくす。
なくすにはforceオプションを使用すればよい。

$ php artisan migrate --force

#詳細

vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php
class MigrateCommand extends BaseCommand {

	use ConfirmableTrait;

vendor/laravel/framework/src/Illuminate/Console/ConfirmableTrait.php
trait ConfirmableTrait {
	//...
	public function confirmToProceed($warning = 'Application In Production!', Closure $callback = null)
	{
		$shouldConfirm = $callback ?: $this->getDefaultConfirmCallback();

		if (call_user_func($shouldConfirm))
		{
			if ($this->option('force')) return true;
			//...
		}
	//...
	}
	//...
	protected function getDefaultConfirmCallback()
	{
		return function() { return $this->getLaravel()->environment() == 'production'; };
	}

のように

  • productionのときだけconfirmが実行される
  • forceオプションが付いてたらスルーする

と実装されている。

16
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?