Fix dropping unique/indexes

This commit is contained in:
Sergey Makinen
2017-05-15 20:50:13 +03:00
parent 4104235258
commit 118fc08af8
2 changed files with 25 additions and 0 deletions

View File

@ -119,6 +119,23 @@ class QueryBuilder extends \yii\db\QueryBuilder
return 'SELECT CASE WHEN EXISTS(' . $rawSql . ') THEN 1 ELSE 0 END';
}
/**
* @inheritDoc
* @see http://www.cubrid.org/manual/93/en/sql/schema/table.html#drop-index-clause
*/
public function dropIndex($name, $table)
{
/** @var Schema $schema */
$schema = $this->db->getSchema();
foreach ($schema->getTableUniques($table) as $unique) {
if ($unique->name === $name) {
return $this->dropUnique($name, $table);
}
}
return 'DROP INDEX ' . $this->db->quoteTableName($name) . ' ON ' . $this->db->quoteTableName($table);
}
/**
* @inheritDoc
* @throws NotSupportedException this is not supported by CUBRID.

View File

@ -120,6 +120,14 @@ class QueryBuilder extends \yii\db\QueryBuilder
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' DROP PRIMARY KEY';
}
/**
* @inheritDoc
*/
public function dropUnique($name, $table)
{
return $this->dropIndex($name, $table);
}
/**
* @inheritDoc
* @throws NotSupportedException this is not supported by MySQL.