Allow defaultTableOptions to be overridden from configuration.

Signed-off-by: Yip Rui Fung <rf@yrf.me>
This commit is contained in:
Yip Rui Fung 2021-02-04 13:52:17 +08:00
parent df9ce19a6b
commit af92e6f7eb
2 changed files with 22 additions and 7 deletions

View File

@ -1512,6 +1512,21 @@ $CONFIG = [
*/
'mysql.utf8mb4' => false,
/**
* This configuration parameter can be used to override the default options used for table creation.
* This parameter will take precedence over mysql.utf8mb4 if that is set to true.
*
* An example use for this parameter is where MariaDB page compression is enabled by default as the
* COMPRESSED row format is not allowed there, and thus table creation will fail.
* This option can then be used to override this and change/remove the row_format option.
*
*/
'dbdefaulttableoptions' => [
'collate' => 'utf8mb4_bin',
'charset' => 'utf8mb4',
'row_format' => 'compressed'
],
/**
* Database types that are supported for installation.
*

View File

@ -216,20 +216,20 @@ class ConnectionFactory {
}
// set default table creation options
$connectionParams['defaultTableOptions'] = [
'collate' => 'utf8_bin',
'tablePrefix' => $connectionParams['tablePrefix']
];
$connectionParams['defaultTableOptions'] = $this->config->getValue('dbdefaulttableoptions', [
'collate' => 'utf8_bin'
]);
if ($this->config->getValue('mysql.utf8mb4', false)) {
if ($this->config->getValue('mysql.utf8mb4', false) && is_null($this->config->getValue('dbdefaulttableoptions'))) {
$connectionParams['defaultTableOptions'] = [
'collate' => 'utf8mb4_bin',
'charset' => 'utf8mb4',
'row_format' => 'compressed',
'tablePrefix' => $connectionParams['tablePrefix']
'row_format' => 'compressed'
];
}
$connectionParams['defaultTableOptions']['tablePrefix'] = $connectionParams['tablePrefix'];
return $connectionParams;
}