[SCHEMA] Fix a few mistakes

This commit is contained in:
Alexei Sorokin 2020-07-31 18:24:12 +03:00 committed by Diogo Peralta Cordeiro
parent 50dd216f44
commit 573cd7d450
3 changed files with 11 additions and 27 deletions

View File

@ -363,28 +363,6 @@ class MysqlSchema extends Schema
return 'InnoDB';
}
/**
* Get the unique index key name for a given column on this table
* @param $tableName
* @param $columnName
* @return string
*/
public function _uniqueKey($tableName, $columnName)
{
return $this->_key($tableName, $columnName);
}
/**
* Get the index key name for a given column on this table
* @param $tableName
* @param $columnName
* @return string
*/
public function _key($tableName, $columnName)
{
return "{$tableName}_{$columnName}_idx";
}
/**
* Append phrase(s) to an array of partial ALTER TABLE chunks in order
* to alter the given column from its old state to a new one.
@ -427,6 +405,11 @@ class MysqlSchema extends Schema
$phrase[] = 'DROP INDEX ' . $keyName;
}
public function appendAlterDropForeign(array &$phrase, $keyName)
{
$phrase[] = 'DROP FOREIGN KEY ' . $keyName;
}
/**
* Throw some table metadata onto the ALTER TABLE if we have a mismatch
* in expected type, collation.

View File

@ -371,6 +371,8 @@ class PgsqlSchema extends Schema
foreach ($tableDef['fields'] as $name => &$col) {
// No convenient support for field descriptions
unset($col['description']);
// @fixme Nor for MariaDB-specific collations
unset($col['collate']);
if ($col['type'] === 'serial') {
$col['type'] = 'int';

View File

@ -764,10 +764,10 @@ class Schema
$phrase[] = $prefix . ' DROP NOT NULL';
}
if (!($old['default'] ?? false) && ($cd['default'] ?? false)) {
$phrase[] = $prefix . ' SET DEFAULT ' . $this->quoteDefaultValue($cd);
} elseif (($old['default'] ?? false) && !($cd['default'] ?? false)) {
if (!is_null($old['default'] ?? null) && is_null($cd['default'] ?? null)) {
$phrase[] = $prefix . ' DROP DEFAULT';
} elseif (($old['default'] ?? null) !== ($cd['default'] ?? null)) {
$phrase[] = $prefix . ' SET DEFAULT ' . $this->quoteDefaultValue($cd);
}
}
@ -819,7 +819,7 @@ class Schema
public function appendAlterDropForeign(array &$phrase, $keyName)
{
$phrase[] = 'DROP FOREIGN KEY ' . $keyName;
$phrase[] = 'DROP CONSTRAINT ' . $keyName;
}
public function appendAlterExtras(array &$phrase, $tableName, array $def)
@ -1043,7 +1043,6 @@ class Schema
$col['type'] = 'datetime';
if (!array_key_exists('default', $col)) {
$col['default'] = 'CURRENT_TIMESTAMP';
$col['auto_update_timestamp'] = true;
}
// no break
case 'datetime':