2022-04-14 23:11:35 -07:00
|
|
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
import config = require('../../../../config');
|
|
|
|
|
|
|
|
export class LowerCaseUserEmail1648740597343 implements MigrationInterface {
|
|
|
|
name = 'LowerCaseUserEmail1648740597343';
|
|
|
|
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
let tablePrefix = config.get('database.tablePrefix');
|
|
|
|
const schema = config.get('database.postgresdb.schema');
|
|
|
|
if (schema) {
|
|
|
|
tablePrefix = schema + '.' + tablePrefix;
|
|
|
|
}
|
|
|
|
|
2022-05-30 02:33:17 -07:00
|
|
|
await queryRunner.query(`SET search_path TO ${schema};`);
|
|
|
|
|
2022-04-14 23:11:35 -07:00
|
|
|
await queryRunner.query(`
|
|
|
|
UPDATE ${tablePrefix}user
|
|
|
|
SET email = LOWER(email);
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
|
|
|
}
|