2020-07-26 02:33:20 -07:00
import { MigrationInterface , QueryRunner } from "typeorm" ;
2020-07-17 08:08:40 -07:00
2021-06-23 02:20:07 -07:00
import * as config from '../../../../config' ;
2020-07-17 08:08:40 -07:00
export class CreateIndexStoppedAt1594828256133 implements MigrationInterface {
2020-07-26 02:33:20 -07:00
name = 'CreateIndexStoppedAt1594828256133' ;
2020-07-17 08:08:40 -07:00
2020-07-26 02:33:20 -07:00
async up ( queryRunner : QueryRunner ) : Promise < void > {
2022-04-08 10:37:27 -07:00
let tablePrefix = config . getEnv ( 'database.tablePrefix' ) ;
2020-07-17 08:08:40 -07:00
const tablePrefixPure = tablePrefix ;
2022-04-08 10:37:27 -07:00
const schema = config . getEnv ( 'database.postgresdb.schema' ) ;
2020-07-17 08:08:40 -07:00
if ( schema ) {
tablePrefix = schema + '.' + tablePrefix ;
}
2022-05-30 02:33:17 -07:00
await queryRunner . query ( ` SET search_path TO ${ schema } ; ` ) ;
2020-07-17 08:08:40 -07:00
await queryRunner . query ( ` CREATE INDEX IF NOT EXISTS IDX_ ${ tablePrefixPure } 33228da131bb1112247cf52a42 ON ${ tablePrefix } execution_entity ("stoppedAt") ` ) ;
2020-07-26 02:33:20 -07:00
}
2020-07-17 08:08:40 -07:00
2020-07-26 02:33:20 -07:00
async down ( queryRunner : QueryRunner ) : Promise < void > {
2022-05-30 02:33:17 -07:00
let tablePrefix = config . getEnv ( 'database.tablePrefix' ) ;
2020-07-17 08:08:40 -07:00
2022-05-30 02:33:17 -07:00
const tablePrefixPure = tablePrefix ;
const schema = config . getEnv ( 'database.postgresdb.schema' ) ;
if ( schema ) {
tablePrefix = schema + '.' + tablePrefix ;
}
await queryRunner . query ( ` SET search_path TO ${ schema } ; ` ) ;
await queryRunner . query ( ` DROP INDEX IDX_ ${ tablePrefixPure } 33228da131bb1112247cf52a42 ` ) ;
2020-07-26 02:33:20 -07:00
}
2020-07-17 08:08:40 -07:00
}