public function fire()
{
$complete = $this->option('complete');
$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->getUpdateSchemaSql($metadata, $complete);
if (!count($sqlToRun)) {
$this->info('Your database is already in sync with your model.');
return;
}
if ($sqlOnly) {
$this->info('Here\'s the SQL that currently needs to run:');
$this->info(implode(';' . PHP_EOL, $sqlToRun));
} else {
$this->info('Updating database schema...');
$schemaTool->updateSchema($metadata, $complete);
$this->info('Database schema updated successfully!');
}
}