refactor(core): Improve DB directory setup (#3502)

This commit is contained in:
Iván Ovejero
2022-06-18 07:15:03 +02:00
committed by GitHub
parent d18a29d588
commit 189009a8b7
55 changed files with 120 additions and 143 deletions

View File

@@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import config from '../../../../config';
export class AddAPIKeyColumn1652905585850 implements MigrationInterface {
name = 'AddAPIKeyColumn1652905585850';
public async up(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.getEnv('database.tablePrefix');
await queryRunner.query(
'ALTER TABLE `' + tablePrefix + 'user` ADD COLUMN `apiKey` VARCHAR(255)',
);
await queryRunner.query(
'CREATE UNIQUE INDEX `UQ_' +
tablePrefix +
'ie0zomxves9w3p774drfrkxtj5` ON `' +
tablePrefix +
'user` (`apiKey`)',
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.get('database.tablePrefix');
await queryRunner.query(
'DROP INDEX `IDX_81fc04c8a17de15835713505e4` ON `' + tablePrefix + 'execution_entity`',
);
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'user` DROP COLUMN `apiKey`');
}
}