Geeklog-Core / geeklog

Geeklog - The Secure CMS.
https://www.geeklog.net
25 stars 19 forks source link

Database upgrade fails when coming from Geeklog 2.0.0 or earlier #1153

Open dhaun opened 1 year ago

dhaun commented 1 year ago

This took me a while to track down. As it says in the comment for $_TABLES['topic_assignments'] in mysql_tableanddata.php, the max. size for the PRIMARY KEY is approaching 1000 bytes, which is a limitation in some MySQL versions.

However, that limit is actually hit during the upgrade from Geeklog 2.0.0 to 2.1.0:

$_SQL[] = "ALTER TABLE {$_TABLES['topic_assignments']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL";
$_SQL[] = "ALTER TABLE {$_TABLES['topic_assignments']} CHANGE `id` `id` VARCHAR(128) NOT NULL";

from sql/updates/mysql_2.0.0_to_2.1.0.php, lines 25+26

So you end up with len(tid + id + type) = 286, which is 1144 bytes for the utf8mb4 collation.

Simply commenting out / removing line 25 (for the tid) in mysql_2.0.0_to_2.1.0.php fixes the problem for me, but I'm not sure if that's the best approach.