import { MigrationInterface , QueryRunner } from 'typeorm' ; import { MdsNamingStrategy } from './naming-strategies' ; const strategy = new MdsNamingStrategy ( ) ; export const CreateRepositoryMigration = ( migrationTableName ) => { const migrationIndexName = strategy . indexName ( migrationTableName , [ 'name' ] ) ; return class CreateRepository0000000000001 implements MigrationInterface { name = 'CreateRepository0000000000001' ; public async up ( queryRunner ) { await queryRunner . query ( `CREATE UNIQUE INDEX "${ migrationIndexName }" ON "${ migrationTableName }" ("name") ` , undefined ) ; } public async down ( queryRunner ) { await queryRunner . query ( `DROP INDEX "${ migrationIndexName }"` , undefined ) ; } } ; } ;