Commit fc376f7a authored by Marco Pivetta's avatar Marco Pivetta

Merge branch 'fix/#2611-#2508-pass-through-index-options-when-renaming-indexes' into 2.5

Backport #2611 to 2.5
Backport #2508 to 2.5
parents 8a13144a 2437390c
......@@ -253,10 +253,10 @@ class Table extends AbstractAsset
unset($this->_indexes[$oldIndexName]);
if ($oldIndex->isUnique()) {
return $this->addUniqueIndex($oldIndex->getColumns(), $newIndexName);
return $this->addUniqueIndex($oldIndex->getColumns(), $newIndexName, $oldIndex->getOptions());
}
return $this->addIndex($oldIndex->getColumns(), $newIndexName, $oldIndex->getFlags());
return $this->addIndex($oldIndex->getColumns(), $newIndexName, $oldIndex->getFlags(), $oldIndex->getOptions());
}
/**
......
......@@ -741,6 +741,34 @@ class TableTest extends \Doctrine\Tests\DbalTestCase
$this->assertTrue($table->hasIndex('UNIQ_D87F7E0C76FF8CAA78240498'));
}
/**
* @group DBAL-2508
*/
public function testKeepsIndexOptionsOnRenamingRegularIndex()
{
$table = new Table('foo');
$table->addColumn('id', 'integer');
$table->addIndex(array('id'), 'idx_bar', array(), array('where' => '1 = 1'));
$table->renameIndex('idx_bar', 'idx_baz');
$this->assertSame(array('where' => '1 = 1'), $table->getIndex('idx_baz')->getOptions());
}
/**
* @group DBAL-2508
*/
public function testKeepsIndexOptionsOnRenamingUniqueIndex()
{
$table = new Table('foo');
$table->addColumn('id', 'integer');
$table->addUniqueIndex(array('id'), 'idx_bar', array('where' => '1 = 1'));
$table->renameIndex('idx_bar', 'idx_baz');
$this->assertSame(array('where' => '1 = 1'), $table->getIndex('idx_baz')->getOptions());
}
/**
* @group DBAL-234
* @expectedException \Doctrine\DBAL\Schema\SchemaException
......
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