Commit 6d79c6d6 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Fixed dropIndex()

parent abfc3fb8
...@@ -129,6 +129,7 @@ DROP DATABASE ' . $name . ';'; ...@@ -129,6 +129,7 @@ DROP DATABASE ' . $name . ';';
public function getDropIndexSQL($index, $table=null) public function getDropIndexSQL($index, $table=null)
{ {
if($index instanceof \Doctrine\DBAL\Schema\Index) { if($index instanceof \Doctrine\DBAL\Schema\Index) {
$index_ = $index;
$index = $index->getName(); $index = $index->getName();
} else if(!is_string($index)) { } else if(!is_string($index)) {
throw new \InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'); throw new \InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
...@@ -137,7 +138,15 @@ DROP DATABASE ' . $name . ';'; ...@@ -137,7 +138,15 @@ DROP DATABASE ' . $name . ';';
if (!isset($table)) { if (!isset($table)) {
return 'DROP INDEX ' . $index; return 'DROP INDEX ' . $index;
} else { } else {
return 'DROP INDEX ' . $index . ' ON ' . $table; if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
}
if (!isset($index_) || $index_->isPrimary() || $index_->isUnique()) {
return 'ALTER TABLE ' . $table .' DROP CONSTRAINT ' . $index;
} else {
return 'DROP INDEX ' . $index . ' ON ' . $table;
}
} }
} }
...@@ -178,6 +187,7 @@ DROP DATABASE ' . $name . ';'; ...@@ -178,6 +187,7 @@ DROP DATABASE ' . $name . ';';
} }
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff)); $sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff));
return $sql; return $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