diff --git a/lib/database/mysqlschema.php b/lib/database/mysqlschema.php index 105ef54512..9b710b2902 100644 --- a/lib/database/mysqlschema.php +++ b/lib/database/mysqlschema.php @@ -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. diff --git a/lib/database/pgsqlschema.php b/lib/database/pgsqlschema.php index 046a3bd43d..38f7566eaf 100644 --- a/lib/database/pgsqlschema.php +++ b/lib/database/pgsqlschema.php @@ -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'; diff --git a/lib/database/schema.php b/lib/database/schema.php index 05530db6f1..f472388bd7 100644 --- a/lib/database/schema.php +++ b/lib/database/schema.php @@ -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':