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 +}