Files
Automata/packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts
Ben Hesseldieck ebe2775701 ⚡ Add index stopped at (#766)
* 🚧 add index on sqlite

* 🚧 add migration for postgres

* 🚧 add mysql migration

* 🚧 add mongodb migration

* ⏪ revert change of default postgresdb user
2020-07-17 17:08:40 +02:00

26 lines
894 B
TypeScript

import {MigrationInterface, QueryRunner} from "typeorm";
import * as config from '../../../../config';
export class CreateIndexStoppedAt1594828256133 implements MigrationInterface {
name = 'CreateIndexStoppedAt1594828256133'
public async up(queryRunner: QueryRunner): Promise<void> {
let tablePrefix = config.get('database.tablePrefix');
const tablePrefixPure = tablePrefix;
const schema = config.get('database.postgresdb.schema');
if (schema) {
tablePrefix = schema + '.' + tablePrefix;
}
await queryRunner.query(`CREATE INDEX IF NOT EXISTS IDX_${tablePrefixPure}33228da131bb1112247cf52a42 ON ${tablePrefix}execution_entity ("stoppedAt") `);
}
public async down(queryRunner: QueryRunner): Promise<void> {
let tablePrefix = config.get('database.tablePrefix');
await queryRunner.query(`DROP INDEX IDX_${tablePrefix}33228da131bb1112247cf52a42`);
}
}