Commit 036abc08 authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #2611 from deeky666/DBAL-2508

[DBAL-2508] Pass through index options when renaming index on table
parents 4f7df7c1 ccc3d3be
......@@ -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