From 1324da1fe50a5864d5444cdc7bc87cff7b57f3d1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 26 Jan 2022 15:13:54 +0100 Subject: [PATCH] fix collate conversion due to inconsistencies with encoding --- database/migrations/0006-login_users_collation.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/database/migrations/0006-login_users_collation.ts b/database/migrations/0006-login_users_collation.ts index 579bb0a7a..2a730f5e7 100644 --- a/database/migrations/0006-login_users_collation.ts +++ b/database/migrations/0006-login_users_collation.ts @@ -6,11 +6,13 @@ */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // Explicitly change the charset and collate to the one used to then change it + await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;') await queryFn( 'ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', ) } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { - await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8mb4;') + await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;') }