Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to check only is all migrations have been generated #9

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Command/DiffFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Version as DbalVersion;
use Doctrine\DBAL\Migrations\Provider\OrmSchemaProvider;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
Expand All @@ -16,6 +17,13 @@
*/
class DiffFileCommand extends \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand
{
protected function configure()
{
parent::configure();

$this->addOption('check', null, InputOption::VALUE_NONE, 'Check that all migrations have been created.')
}

/**
*
* @param InputInterface $input
Expand All @@ -40,6 +48,8 @@ public function execute(InputInterface $input, OutputInterface $output)
->setFilterSchemaAssetsExpression($filterExpr);
}

$checkOnly = $input->getOption('check');

$fromSchema = $this->getLastSchemaDefinition($configuration);
$toSchema = $this->getSchemaProvider()->createSchema();

Expand All @@ -62,6 +72,11 @@ public function execute(InputInterface $input, OutputInterface $output)
return;
}

if ($checkOnly) {
$output->writeln('<error>Changes detected in your mapping information!</error>');
exit(1);
}

$version = date('YmdHis');
$path = $this->generateMigration($configuration, $input, $version, $up, $down);

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ So you only have to run the command before doing a new version of your app.
php bin/console doctrine:migrations:diff-file

A version file will be generated (if required) and your current schema will be dumped in a file. (in /app/DoctrineMigrations/SchemaVersion)

You can automatically check that the migrations have been generated using the check option

php bin/console doctrine:migrations:diff-file --check

The exit code 1 will be used if a migration should have been generated