* use utf8mb4 charset in mysql database

This commit is contained in:
Max Pozdeev 2021-07-28 18:50:23 +03:00
parent 9dd8071bc6
commit 39c9d1608d
2 changed files with 15 additions and 5 deletions

View file

@ -56,7 +56,7 @@ if (Config::get('db') == 'mysql')
catch(Exception $e) {
logAndDie("Failed to connect to mysql database: ". $e->getMessage());
}
$db->dq("SET NAMES utf8");
$db->dq("SET NAMES utf8mb4");
}
# SQLite3 Database

View file

@ -115,7 +115,7 @@ if (!$ver)
`taskview` INT UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id`),
UNIQUE KEY(`uuid`)
) CHARSET=utf8 ");
) CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ");
$db->ex(
@ -137,7 +137,7 @@ if (!$ver)
PRIMARY KEY(`id`),
KEY(`list_id`),
UNIQUE KEY(`uuid`)
) CHARSET=utf8 ");
) CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ");
$db->ex(
@ -146,7 +146,7 @@ if (!$ver)
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE KEY `name` (`name`)
) CHARSET=utf8 ");
) CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ");
$db->ex(
@ -157,7 +157,7 @@ if (!$ver)
KEY(`tag_id`),
KEY(`task_id`),
KEY(`list_id`) /* for tagcloud */
) CHARSET=utf8 ");
) CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ");
$db->ex(
@ -398,6 +398,15 @@ function update_14_17(Database_Abstract $db, $dbtype)
$db->ex("BEGIN");
if($dbtype=='mysql')
{
# convert charset to utf8mb4
$db->ex("ALTER TABLE {$db->prefix}lists CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
$db->ex("ALTER TABLE {$db->prefix}todolist CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
$db->ex("ALTER TABLE {$db->prefix}tags CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
$db->ex("ALTER TABLE {$db->prefix}tag2task CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
# create settings table
$db->ex(
"CREATE TABLE {$db->prefix}settings (
`param_key` VARCHAR(100) NOT NULL default '',
@ -405,6 +414,7 @@ function update_14_17(Database_Abstract $db, $dbtype)
UNIQUE KEY `param_key` (`param_key`)
) CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ");
}
else #sqlite
{
$db->ex(