Commit aedfbf26 authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-586] Fix failures introduced by PR and adjust code.

parent fd288786
...@@ -623,15 +623,6 @@ class MySqlPlatform extends AbstractPlatform ...@@ -623,15 +623,6 @@ class MySqlPlatform extends AbstractPlatform
} }
} }
} }
foreach ($diff->changedIndexes as $changedKey => $changedIndex) {
if ($changedIndex->isPrimary() && $changedKey != 'PRIMARY') {
$index = $diff->changedIndexes[$changedKey];
$index = new Index($changedKey, $index->getColumns(), $index->isUnique(), false);
$diff->removedIndexes[$changedKey] = $index;
$diff->addedIndexes['PRIMARY'] = $diff->changedIndexes[$changedKey];
unset($diff->changedIndexes[$changedKey]);
}
}
$sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff)); $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));
......
...@@ -296,6 +296,28 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -296,6 +296,28 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$this->assertEquals('LONGBLOB', $this->_platform->getBlobTypeDeclarationSQL(array())); $this->assertEquals('LONGBLOB', $this->_platform->getBlobTypeDeclarationSQL(array()));
} }
/**
* @group DBAL-400
*/
public function testAlterTableAddPrimaryKey()
{
$table = new Table('alter_table_add_pk');
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
$table->addIndex(array('id'), 'idx_id');
$comparator = new Comparator();
$diffTable = clone $table;
$diffTable->dropIndex('idx_id');
$diffTable->setPrimaryKey(array('id'));
$this->assertEquals(
array('DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'),
$this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
/** /**
* @group DBAL-464 * @group DBAL-464
*/ */
...@@ -352,7 +374,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -352,7 +374,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$sql = $this->_platform->getAlterTableSQL($diff); $sql = $this->_platform->getAlterTableSQL($diff);
$this->assertEquals(array( $this->assertEquals(array(
"DROP INDEX foo_index ON mytable", "ALTER TABLE mytable DROP PRIMARY KEY",
"ALTER TABLE mytable ADD PRIMARY KEY (foo)", "ALTER TABLE mytable ADD PRIMARY KEY (foo)",
), $sql); ), $sql);
} }
......
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