mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
Fix dropping unique/indexes
This commit is contained in:
@ -119,6 +119,23 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
return 'SELECT CASE WHEN EXISTS(' . $rawSql . ') THEN 1 ELSE 0 END';
|
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
|
* @inheritDoc
|
||||||
* @throws NotSupportedException this is not supported by CUBRID.
|
* @throws NotSupportedException this is not supported by CUBRID.
|
||||||
|
|||||||
@ -120,6 +120,14 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' DROP PRIMARY KEY';
|
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' DROP PRIMARY KEY';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function dropUnique($name, $table)
|
||||||
|
{
|
||||||
|
return $this->dropIndex($name, $table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @throws NotSupportedException this is not supported by MySQL.
|
* @throws NotSupportedException this is not supported by MySQL.
|
||||||
|
|||||||
Reference in New Issue
Block a user