Laravelのコマンドはコードを読んでみると実はいろんなオプションがついていたりします。
db:wipeコマンド
db:wipe
コマンドでdbのtableをdropできるのですが、実はdb:wipe --drop-views
とするとviewも削除することができます。
migrate:freshコマンド
またmigrateを最初からやり直すmigrate:fresh
コマンドがありますが、viewを作っている場合はviewの作成も最初からやり直さないとviewだけ残ってしまいます。
これを解決するにはmigrate:fresh --drop-views
とすることでviewも削除することができます。
コードを読んでみると
FreshCommand.php
<?php
namespace Illuminate\Database\Console\Migrations;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Input\InputOption;
class FreshCommand extends Command
{
use ConfirmableTrait;
/**
* The console command name.
*
* @var string
*/
protected $name = 'migrate:fresh';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Drop all tables and re-run all migrations';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
if (! $this->confirmToProceed()) {
return;
}
$database = $this->input->getOption('database');
$this->call('db:wipe', array_filter([
'--database' => $database,
'--drop-views' => $this->option('drop-views'),
'--drop-types' => $this->option('drop-types'),
'--force' => true,
]));
$this->call('migrate', array_filter([
'--database' => $database,
'--path' => $this->input->getOption('path'),
'--realpath' => $this->input->getOption('realpath'),
'--force' => true,
'--step' => $this->option('step'),
]));
if ($this->needsSeeding()) {
$this->runSeeder($database);
}
}
... 略 ...
}
となっていて、--drop-viewがdb:wipeコマンドに渡されているのがわかりますね。