Issue #2522120 by jhedstrom: DbDumpCommand should add collation information to the generated script
parent
b04d55edfe
commit
90b4ae4c4a
|
@ -220,6 +220,9 @@ class DbDumpCommand extends Command {
|
||||||
// Set primary key, unique keys, and indexes.
|
// Set primary key, unique keys, and indexes.
|
||||||
$this->getTableIndexes($table, $definition);
|
$this->getTableIndexes($table, $definition);
|
||||||
|
|
||||||
|
// Set table collation.
|
||||||
|
$this->getTableCollation($table, $definition);
|
||||||
|
|
||||||
return $definition;
|
return $definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +238,6 @@ class DbDumpCommand extends Command {
|
||||||
// Note, this query doesn't support ordering, so that is worked around
|
// Note, this query doesn't support ordering, so that is worked around
|
||||||
// below by keying the array on Seq_in_index.
|
// below by keying the array on Seq_in_index.
|
||||||
$query = $this->connection->query("SHOW INDEX FROM {" . $table . "}");
|
$query = $this->connection->query("SHOW INDEX FROM {" . $table . "}");
|
||||||
$indexes = [];
|
|
||||||
while (($row = $query->fetchAssoc()) !== FALSE) {
|
while (($row = $query->fetchAssoc()) !== FALSE) {
|
||||||
$index_name = $row['Key_name'];
|
$index_name = $row['Key_name'];
|
||||||
$column = $row['Column_name'];
|
$column = $row['Column_name'];
|
||||||
|
@ -259,6 +261,22 @@ class DbDumpCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Gets all data from a given table.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue