Commit 90b4ae4c authored by catch's avatar catch

Issue #2522120 by jhedstrom: DbDumpCommand should add collation information to the generated script

parent b04d55ed
......@@ -220,6 +220,9 @@ protected function getTableSchema($table) {
// Set primary key, unique keys, and indexes.
$this->getTableIndexes($table, $definition);
// Set table collation.
$this->getTableCollation($table, $definition);
return $definition;
}
......@@ -235,7 +238,6 @@ protected function getTableIndexes($table, &$definition) {
// Note, this query doesn't support ordering, so that is worked around
// below by keying the array on Seq_in_index.
$query = $this->connection->query("SHOW INDEX FROM {" . $table . "}");
$indexes = [];
while (($row = $query->fetchAssoc()) !== FALSE) {
$index_name = $row['Key_name'];
$column = $row['Column_name'];
......@@ -259,6 +261,22 @@ protected function getTableIndexes($table, &$definition) {
}
}
/**
* Set the table collation.
*
* @param string $table
* The table to find indexes for.
* @param array &$definition
* The schema definition to modify.
*/
protected function getTableCollation($table, &$definition) {
$query = $this->connection->query("SHOW TABLE STATUS LIKE '{" . $table . "}'");
$data = $query->fetchAssoc();
// Set `mysql_character_set`. This will be ignored by other backends.
$definition['mysql_character_set'] = str_replace('_general_ci', '', $data['Collation']);
}
/**
* Gets all data from a given table.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment