Permalink
Browse files

Re-added support for Doctrine 2.1

  • Loading branch information...
stof committed Sep 19, 2012
1 parent c776e06 commit 3dd738b2a709f4d5185c144292189c6e708ca37d
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/Doctrine/DBAL/Migrations/Tools/Console/Command/DiffCommand.php
@@ -24,6 +24,7 @@
Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Doctrine\ORM\Tools\SchemaTool,
+ Doctrine\DBAL\Version as DbalVersion,
Doctrine\DBAL\Migrations\Configuration\Configuration;
/**
@@ -59,6 +60,7 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
+ $isDbalOld = (DbalVersion::compare('2.2.0') > 0);
$configuration = $this->getMigrationConfiguration($input, $output);
$em = $this->getHelper('em')->getEntityManager();
@@ -72,17 +74,21 @@ public function execute(InputInterface $input, OutputInterface $output)
}
if ($filterExpr = $input->getOption('filter-expression')) {
+ if ($isDbalOld) {
+ throw new \InvalidArgumentException('The "--filter-expression" option can only be used as of Doctrine DBAL 2.2');
+ }
+
$conn->getConfiguration()
->setFilterSchemaAssetsExpression($filterExpr);
}
-
+
$tool = new SchemaTool($em);
$fromSchema = $conn->getSchemaManager()->createSchema();
$toSchema = $tool->getSchemaFromMetadata($metadata);
//Not using value from options, because filters can be set from config.yml
- if ($filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression()) {
+ if ( ! $isDbalOld && $filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression()) {
$tableNames = $toSchema->getTableNames();
foreach ($tableNames as $tableName) {
$tableName = substr($tableName, strpos($tableName, '.') + 1);

0 comments on commit 3dd738b

Please sign in to comment.