diff options
-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"; } } |