[SCHEMA] Fix a few mistakes
This commit is contained in:
parent
50dd216f44
commit
573cd7d450
|
@ -363,28 +363,6 @@ class MysqlSchema extends Schema
|
||||||
return 'InnoDB';
|
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
|
* 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.
|
* 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;
|
$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
|
* Throw some table metadata onto the ALTER TABLE if we have a mismatch
|
||||||
* in expected type, collation.
|
* in expected type, collation.
|
||||||
|
|
|
@ -371,6 +371,8 @@ class PgsqlSchema extends Schema
|
||||||
foreach ($tableDef['fields'] as $name => &$col) {
|
foreach ($tableDef['fields'] as $name => &$col) {
|
||||||
// No convenient support for field descriptions
|
// No convenient support for field descriptions
|
||||||
unset($col['description']);
|
unset($col['description']);
|
||||||
|
// @fixme Nor for MariaDB-specific collations
|
||||||
|
unset($col['collate']);
|
||||||
|
|
||||||
if ($col['type'] === 'serial') {
|
if ($col['type'] === 'serial') {
|
||||||
$col['type'] = 'int';
|
$col['type'] = 'int';
|
||||||
|
|
|
@ -764,10 +764,10 @@ class Schema
|
||||||
$phrase[] = $prefix . ' DROP NOT NULL';
|
$phrase[] = $prefix . ' DROP NOT NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($old['default'] ?? false) && ($cd['default'] ?? false)) {
|
if (!is_null($old['default'] ?? null) && is_null($cd['default'] ?? null)) {
|
||||||
$phrase[] = $prefix . ' SET DEFAULT ' . $this->quoteDefaultValue($cd);
|
|
||||||
} elseif (($old['default'] ?? false) && !($cd['default'] ?? false)) {
|
|
||||||
$phrase[] = $prefix . ' DROP DEFAULT';
|
$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)
|
public function appendAlterDropForeign(array &$phrase, $keyName)
|
||||||
{
|
{
|
||||||
$phrase[] = 'DROP FOREIGN KEY ' . $keyName;
|
$phrase[] = 'DROP CONSTRAINT ' . $keyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function appendAlterExtras(array &$phrase, $tableName, array $def)
|
public function appendAlterExtras(array &$phrase, $tableName, array $def)
|
||||||
|
@ -1043,7 +1043,6 @@ class Schema
|
||||||
$col['type'] = 'datetime';
|
$col['type'] = 'datetime';
|
||||||
if (!array_key_exists('default', $col)) {
|
if (!array_key_exists('default', $col)) {
|
||||||
$col['default'] = 'CURRENT_TIMESTAMP';
|
$col['default'] = 'CURRENT_TIMESTAMP';
|
||||||
$col['auto_update_timestamp'] = true;
|
|
||||||
}
|
}
|
||||||
// no break
|
// no break
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user