Skip to content

Commit

Permalink
Merge pull request #9 from A5sys/ci-check
Browse files Browse the repository at this point in the history
option to check only is all migrations have been generated
  • Loading branch information
thomasbeaujean authored Jan 24, 2019
2 parents 8a708b6 + 9d82a76 commit 5c3316b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 5c3316b

Please sign in to comment.