public function fire()
{
$sqlOnly = $this->option('sql');
$this->comment('ATTENTION: This operation should not be executed in a production environment.');
$this->info('Obtaining metadata from your models...');
$metadata = $this->laravel->make('\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->getAllMetadata();
$schemaTool = $this->laravel->make('\\Doctrine\\ORM\\Tools\\SchemaTool');
$sqlToRun = $schemaTool->getDropSchemaSql($metadata);
if (!count($sqlToRun)) {
$this->info('None of your current models exist in the schema.');
return;
}
if ($sqlOnly) {
$this->info('Here\'s the SQL to drop your models from the schema:');
$this->info(implode(';' . PHP_EOL, $sqlToRun));
} else {
$this->info('Dropping all models from the current schema...');
$schemaTool->dropSchema($metadata);
$this->info('Database schema updated successfully!');
}
}