Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new commands from Migrations 2.0
- Loading branch information
Showing
12 changed files
with
192 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\MigrationsBundle\Command; | ||
|
||
use Doctrine\Migrations\Tools\Console\Command\DumpSchemaCommand; | ||
use InvalidArgumentException; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Command for dumping your current database schema to a migration. | ||
*/ | ||
class MigrationsDumpSchemaDoctrineCommand extends DumpSchemaCommand | ||
{ | ||
protected function configure() : void | ||
{ | ||
parent::configure(); | ||
|
||
$this | ||
->setName('doctrine:migrations:dump-schema') | ||
->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') | ||
->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') | ||
->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.') | ||
; | ||
} | ||
|
||
public function initialize(InputInterface $input, OutputInterface $output) : void | ||
{ | ||
/** @var Application $application */ | ||
$application = $this->getApplication(); | ||
|
||
Helper\DoctrineCommandHelper::setApplicationHelper($application, $input); | ||
|
||
$configuration = $this->getMigrationConfiguration($input, $output); | ||
DoctrineCommand::configureMigrations($application->getKernel()->getContainer(), $configuration); | ||
|
||
parent::initialize($input, $output); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output) : ?int | ||
{ | ||
// EM and DB options cannot be set at same time | ||
if ($input->getOption('em') !== null && $input->getOption('db') !== null) { | ||
throw new InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); | ||
} | ||
|
||
return parent::execute($input, $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\MigrationsBundle\Command; | ||
|
||
use Doctrine\Migrations\Tools\Console\Command\RollupCommand; | ||
use InvalidArgumentException; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Command for rolling up your historical migration versions and inserting the dumped schema version. | ||
*/ | ||
class MigrationsRollupDoctrineCommand extends RollupCommand | ||
{ | ||
protected function configure() : void | ||
{ | ||
parent::configure(); | ||
|
||
$this | ||
->setName('doctrine:migrations:rollup') | ||
->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') | ||
->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') | ||
->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.') | ||
; | ||
} | ||
|
||
public function initialize(InputInterface $input, OutputInterface $output) : void | ||
{ | ||
/** @var Application $application */ | ||
$application = $this->getApplication(); | ||
|
||
Helper\DoctrineCommandHelper::setApplicationHelper($application, $input); | ||
|
||
$configuration = $this->getMigrationConfiguration($input, $output); | ||
DoctrineCommand::configureMigrations($application->getKernel()->getContainer(), $configuration); | ||
|
||
parent::initialize($input, $output); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output) : ?int | ||
{ | ||
// EM and DB options cannot be set at same time | ||
if ($input->getOption('em') !== null && $input->getOption('db') !== null) { | ||
throw new InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); | ||
} | ||
|
||
return parent::execute($input, $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\MigrationsBundle\Command; | ||
|
||
use Doctrine\Migrations\Tools\Console\Command\UpToDateCommand; | ||
use InvalidArgumentException; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Command for checking if your database is up to date or not. | ||
*/ | ||
class MigrationsUpToDateDoctrineCommand extends UpToDateCommand | ||
{ | ||
protected function configure() : void | ||
{ | ||
parent::configure(); | ||
|
||
$this | ||
->setName('doctrine:migrations:up-to-date') | ||
->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') | ||
->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') | ||
->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.') | ||
; | ||
} | ||
|
||
public function initialize(InputInterface $input, OutputInterface $output) : void | ||
{ | ||
/** @var Application $application */ | ||
$application = $this->getApplication(); | ||
|
||
Helper\DoctrineCommandHelper::setApplicationHelper($application, $input); | ||
|
||
$configuration = $this->getMigrationConfiguration($input, $output); | ||
DoctrineCommand::configureMigrations($application->getKernel()->getContainer(), $configuration); | ||
|
||
parent::initialize($input, $output); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output) : ?int | ||
{ | ||
// EM and DB options cannot be set at same time | ||
if ($input->getOption('em') !== null && $input->getOption('db') !== null) { | ||
throw new InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); | ||
} | ||
|
||
return parent::execute($input, $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters