diff options
author | Simon Rettberg | 2022-07-06 15:56:50 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-07-06 15:56:50 +0200 |
commit | 42ca742067d2f88846b1620127b1e792625ee6a8 (patch) | |
tree | bf256306e7faaae29eb6b9fe0fa230b1e66fef6d /install.php | |
parent | [statistics] Fix Chart.js for HDD view (diff) | |
download | slx-admin-42ca742067d2f88846b1620127b1e792625ee6a8.tar.gz slx-admin-42ca742067d2f88846b1620127b1e792625ee6a8.tar.xz slx-admin-42ca742067d2f88846b1620127b1e792625ee6a8.zip |
install.php: Fix charset upgrade statement
Diffstat (limited to 'install.php')
-rw-r--r-- | install.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/install.php b/install.php index 29b734d1..889c77cd 100644 --- a/install.php +++ b/install.php @@ -359,14 +359,17 @@ if ($res['@@character_set_database'] !== 'utf8mb4' || $res['@@collation_database FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = :db AND COLLATION_NAME LIKE 'utf8%' AND COLLATION_NAME <> :collation", ['db' => $db, 'collation' => $COLLATION]); + $idx = 0; foreach ($columns as $c) { + $idx++; $args = []; $str = $c['COLUMN_TYPE'] . ' CHARACTER SET utf8mb4 ' . $c['EXTRA']; if ($c['IS_NULLABLE'] === 'NO') { $str .= ' NOT NULL'; } if (!($c['IS_NULLABLE'] === 'NO' && $c['COLUMN_DEFAULT'] === null)) { - $str .= ' DEFAULT ' . ($c['COLUMN_DEFAULT'] ?? 'NULL'); + $str .= " DEFAULT :def_$idx"; + $args["def_$idx"] = $c['COLUMN_DEFAULT']; } if (!empty($c['COLUMN_COMMENT'])) { $str .= ' COMMENT :comment'; @@ -375,7 +378,8 @@ if ($res['@@character_set_database'] !== 'utf8mb4' || $res['@@collation_database $str .= ' COLLATE ' . $COLLATION; $query = "ALTER TABLE `{$c['TABLE_NAME']}` MODIFY `{$c['COLUMN_NAME']}` $str"; if (Database::exec($query, $args) === false) { - $charsetUpdate .= "\n+++ {$c['TABLE_NAME']}.{$c['COLUMN_NAME']} failed: " . Database::lastError(); + $charsetUpdate .= "\n\n--------------------------\n" . + "+++ {$c['TABLE_NAME']}.{$c['COLUMN_NAME']} failed: " . Database::lastError(); $charsetUpdate .= "\n$query"; } } |