[DATABASE] Make unprefixed schema.php a bit more DBMS-neutral

This commit is contained in:
Alexei Sorokin
2020-07-23 18:12:01 +03:00
parent 0def5f1dca
commit 31dcf99e61
3 changed files with 64 additions and 56 deletions

View File

@@ -379,6 +379,25 @@ class MysqlSchema extends Schema
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.
*
* @param array $phrase
* @param string $columnName
* @param array $old previous column definition as found in DB
* @param array $cd current column definition
*/
public function appendAlterModifyColumn(
array &$phrase,
string $columnName,
array $old,
array $cd
): void {
$phrase[] = 'MODIFY COLUMN ' . $this->quoteIdentifier($columnName)
. ' ' . $this->columnSql($columnName, $cd);
}
/**
* MySQL doesn't take 'DROP CONSTRAINT', need to treat primary keys as
* if they were indexes here, but can use 'PRIMARY KEY' special name.
@@ -427,6 +446,19 @@ class MysqlSchema extends Schema
}
}
/**
* Append an SQL statement to drop an index from a table.
* Note that in MariaDB index names are relation-specific.
*
* @param array $statements
* @param string $table
* @param string $name
*/
public function appendDropIndex(array &$statements, $table, $name)
{
$statements[] = "DROP INDEX {$name} ON {$this->quoteIdentifier($table)}";
}
private function isNumericType(array $cd): bool
{
$ints = array_map(