From aa8e96dd6b19f105a957da71a5c4d7ab5caecc01 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Wed, 3 May 2023 05:04:47 -0400 Subject: [PATCH] fix(core): Fix bug running addUserActivatedColumn migration on MariaDB (#6157) --- .../1681134145996-AddUserActivatedProperty.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts b/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts index e1c193a959935..b08c384c29e14 100644 --- a/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts +++ b/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts @@ -25,13 +25,16 @@ export class AddUserActivatedProperty1681134145996 implements MigrationInterface AND r.scope = 'workflow'`, ); - const updatedUsers = activatedUsers.map((user) => + const updatedUsers = activatedUsers.map((user) => { + /* + MariaDB returns settings as a string and MySQL as a JSON + */ + const userSettings = + typeof user.settings === 'string' ? user.settings : JSON.stringify(user.settings); queryRunner.query( - `UPDATE ${tablePrefix}user SET settings = '${JSON.stringify(user.settings)}' WHERE id = '${ - user.id - }' `, - ), - ); + `UPDATE ${tablePrefix}user SET settings = '${userSettings}' WHERE id = '${user.id}' `, + ); + }); await Promise.all(updatedUsers);