From 7af33a5c9f29b7e0d8157bccaca3e262a97b3206 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 28 Feb 2022 01:57:21 +0100 Subject: [PATCH] migration to convert all emails to lowercase --- database/migrations/0025-emails_to_lower.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 database/migrations/0025-emails_to_lower.ts diff --git a/database/migrations/0025-emails_to_lower.ts b/database/migrations/0025-emails_to_lower.ts new file mode 100644 index 000000000..14ba35261 --- /dev/null +++ b/database/migrations/0025-emails_to_lower.ts @@ -0,0 +1,16 @@ +/* MIGRATION TO MAKE ALL EMAILS LOWERCASE + * + * Make all `email` values in `users` lowercase. + * This allows safe queries without any modificators + */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('UPDATE `users` SET `email` = LOWER(`email`);') +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // This migration cannot be revered +}