Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add the posibility to add a custom Comparator for Schema tool #352

Closed
wants to merge 1 commit into from

4 participants

@travisbot

This pull request fails (merged 4dffe452 into 93fcb74).

@travisbot

This pull request passes (merged 4a0c69cb into 93fcb74).

@travisbot

This pull request passes (merged 32e9f679 into 93fcb74).

@travisbot

This pull request passes (merged 709f1c8c into 93fcb74).

@travisbot

This pull request passes (merged 4749c145 into 93fcb74).

@guilhermeblanco

@catacgc can you rebase?

@travisbot

This pull request fails (merged 93779dd8 into 00a5f18).

@catacgc

@guilhermeblanco rebased - this pull request depends on doctrine/dbal#152

@travisbot

This pull request passes (merged 4460234 into 00a5f18).

@beberlei
Owner

This feature only helps users to avoid reporting/fixing bugs in the DBAL schema support, so closing.

@beberlei beberlei closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 6 deletions.
  1. +21 −6 lib/Doctrine/ORM/Tools/SchemaTool.php
View
27 lib/Doctrine/ORM/Tools/SchemaTool.php
@@ -27,13 +27,15 @@
Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Internal\CommitOrderCalculator,
Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs,
- Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
+ Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs,
+ Doctrine\DBAL\Schema\Comparator,
+ Doctrine\DBAL\Schema\ComparatorInterface;
/**
* The SchemaTool is a tool to create/drop/update database schemas based on
* <tt>ClassMetadata</tt> class descriptors.
*
- *
+ *
* @link www.doctrine-project.org
* @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
@@ -61,6 +63,11 @@ class SchemaTool
private $quoteStrategy;
/**
+ * @var \Doctrine\DBAL\Schema\ComparatorInterface
+ */
+ protected $comparator;
+
+ /**
* Initializes a new SchemaTool instance that uses the connection of the
* provided EntityManager.
*
@@ -71,6 +78,17 @@ public function __construct(EntityManager $em)
$this->em = $em;
$this->platform = $em->getConnection()->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
+ $this->comparator = new Comparator();
+ }
+
+ /**
+ * Sets a custom comparator implementation
+ *
+ * @param ComparatorInterface $comparator
+ */
+ public function setComparator(ComparatorInterface $comparator)
+ {
+ $this->comparator = $comparator;
}
/**
@@ -706,12 +724,9 @@ public function updateSchema(array $classes, $saveMode=false)
public function getUpdateSchemaSql(array $classes, $saveMode=false)
{
$sm = $this->em->getConnection()->getSchemaManager();
-
$fromSchema = $sm->createSchema();
$toSchema = $this->getSchemaFromMetadata($classes);
-
- $comparator = new \Doctrine\DBAL\Schema\Comparator();
- $schemaDiff = $comparator->compare($fromSchema, $toSchema);
+ $schemaDiff = $this->comparator->compare($fromSchema, $toSchema);
if ($saveMode) {
return $schemaDiff->toSaveSql($this->platform);
Something went wrong with that request. Please try again.