Adds schema-update daenerys command.

This commit is contained in:
Basilius Sauter
2019-03-08 13:28:44 +01:00
parent 6b383be1cd
commit 55481c30b1
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Console\Command;
use Doctrine\ORM\Tools\SchemaTool;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use LotGD\Core\Console\Main;
use LotGD\Core\Game;
/**
* Danerys command to initiate the database with default values.
*/
class DatabaseSchemaUpdateCommand extends BaseCommand
{
/**
* @inheritDoc
*/
protected function configure()
{
$this->setName('database:schemaUpdate')
->setDescription('Updates the database schema manually.');
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$entityManager = $this->game->getEntityManager();
$metaData = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($entityManager);
$schemaTool->updateSchema($metaData);
$entityManager->flush();
}
}