Commit f8b1a95d authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #345 from chEbba/comparator-autoincrement-sequence

Prevent autoincrement columns from creating CREATE SEQUENCE statement
parents c727c032 86679aa6
......@@ -112,7 +112,9 @@ class Comparator
foreach ($toSchema->getSequences() as $sequence) {
$sequenceName = $sequence->getShortestName($toSchema->getName());
if ( ! $fromSchema->hasSequence($sequenceName)) {
$diff->newSequences[] = $sequence;
if ( ! $this->isAutoIncrementSequenceInSchema($fromSchema, $sequence)) {
$diff->newSequences[] = $sequence;
}
} else {
if ($this->diffSequence($sequence, $fromSchema->getSequence($sequenceName))) {
$diff->changedSequences[] = $toSchema->getSequence($sequenceName);
......
......@@ -863,6 +863,28 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
}
/**
* Check that added autoincrement sequence is not populated in newSequences
* @group DBAL-562
*/
public function testAutoIncremenetNoSequences()
{
$oldSchema = new Schema();
$table = $oldSchema->createTable("foo");
$table->addColumn("id", "integer", array("autoincrement" => true));
$table->setPrimaryKey(array("id"));
$newSchema = new Schema();
$table = $newSchema->createTable("foo");
$table->addColumn("id", "integer", array("autoincrement" => true));
$table->setPrimaryKey(array("id"));
$newSchema->createSequence("foo_id_seq");
$c = new Comparator();
$diff = $c->compare($oldSchema, $newSchema);
$this->assertCount(0, $diff->newSequences);
}
/**
* You can get multiple drops for a FK when a table referenced by a foreign
* key is deleted, as this FK is referenced twice, once on the orphanedForeignKeys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment