From fc6484ba4d48363fd846d5c800a25a207082f58d Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Sat, 3 Sep 2022 19:02:39 +0100 Subject: [PATCH] fix(core): Fix MySQL migration issue with table prefix (#4013) * Fix mysql migration issue on execution entity * Fix one down migration Co-authored-by: Jan Oberhauser --- ...1644424784709-AddExecutionEntityIndexes.ts | 42 +++++++------------ .../mysqldb/1652905585850-AddAPIKeyColumn.ts | 2 +- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/packages/cli/src/databases/migrations/mysqldb/1644424784709-AddExecutionEntityIndexes.ts b/packages/cli/src/databases/migrations/mysqldb/1644424784709-AddExecutionEntityIndexes.ts index 74215b2995aa0..c96c63518278c 100644 --- a/packages/cli/src/databases/migrations/mysqldb/1644424784709-AddExecutionEntityIndexes.ts +++ b/packages/cli/src/databases/migrations/mysqldb/1644424784709-AddExecutionEntityIndexes.ts @@ -8,64 +8,50 @@ export class AddExecutionEntityIndexes1644424784709 implements MigrationInterfac const tablePrefix = config.getEnv('database.tablePrefix'); await queryRunner.query( - 'DROP INDEX `IDX_c4d999a5e90784e8caccf5589d` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}c4d999a5e90784e8caccf5589d\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'DROP INDEX `IDX_ca4a71b47f28ac6ea88293a8e2` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}ca4a71b47f28ac6ea88293a8e2\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'CREATE INDEX `IDX_06da892aaf92a48e7d3e400003` ON `' + - tablePrefix + - 'execution_entity` (`workflowId`, `waitTill`, `id`)', + `CREATE INDEX \`IDX_${tablePrefix}06da892aaf92a48e7d3e400003\` ON \`${tablePrefix}execution_entity\` (\`workflowId\`, \`waitTill\`, \`id\`)`, ); await queryRunner.query( - 'CREATE INDEX `IDX_78d62b89dc1433192b86dce18a` ON `' + - tablePrefix + - 'execution_entity` (`workflowId`, `finished`, `id`)', + `CREATE INDEX \`IDX_${tablePrefix}78d62b89dc1433192b86dce18a\` ON \`${tablePrefix}execution_entity\` (\`workflowId\`, \`finished\`, \`id\`)`, ); await queryRunner.query( - 'CREATE INDEX `IDX_1688846335d274033e15c846a4` ON `' + - tablePrefix + - 'execution_entity` (`finished`, `id`)', + `CREATE INDEX \`IDX_${tablePrefix}1688846335d274033e15c846a4\` ON \`${tablePrefix}execution_entity\` (\`finished\`, \`id\`)`, ); await queryRunner.query( - 'CREATE INDEX `IDX_b94b45ce2c73ce46c54f20b5f9` ON `' + - tablePrefix + - 'execution_entity` (`waitTill`, `id`)', + `CREATE INDEX \`IDX_${tablePrefix}b94b45ce2c73ce46c54f20b5f9\` ON \`${tablePrefix}execution_entity\` (\`waitTill\`, \`id\`)`, ); await queryRunner.query( - 'CREATE INDEX `IDX_81fc04c8a17de15835713505e4` ON `' + - tablePrefix + - 'execution_entity` (`workflowId`, `id`)', + `CREATE INDEX \`IDX_${tablePrefix}81fc04c8a17de15835713505e4\` ON \`${tablePrefix}execution_entity\` (\`workflowId\`, \`id\`)`, ); } public async down(queryRunner: QueryRunner): Promise { const tablePrefix = config.getEnv('database.tablePrefix'); await queryRunner.query( - 'DROP INDEX `IDX_81fc04c8a17de15835713505e4` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}81fc04c8a17de15835713505e4\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'DROP INDEX `IDX_b94b45ce2c73ce46c54f20b5f9` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}b94b45ce2c73ce46c54f20b5f9\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'DROP INDEX `IDX_1688846335d274033e15c846a4` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}1688846335d274033e15c846a4\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'DROP INDEX `IDX_78d62b89dc1433192b86dce18a` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}78d62b89dc1433192b86dce18a\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'DROP INDEX `IDX_06da892aaf92a48e7d3e400003` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`IDX_${tablePrefix}06da892aaf92a48e7d3e400003\` ON \`${tablePrefix}execution_entity\``, ); await queryRunner.query( - 'CREATE INDEX `IDX_ca4a71b47f28ac6ea88293a8e2` ON `' + - tablePrefix + - 'execution_entity` (`waitTill`)', + `CREATE INDEX \`IDX_${tablePrefix}ca4a71b47f28ac6ea88293a8e2\` ON \`${tablePrefix}execution_entity\` (\`waitTill\`)`, ); await queryRunner.query( - 'CREATE INDEX `IDX_c4d999a5e90784e8caccf5589d` ON `' + - tablePrefix + - 'execution_entity` (`workflowId`)', + `CREATE INDEX \`IDX_${tablePrefix}c4d999a5e90784e8caccf5589d\` ON \`${tablePrefix}execution_entity\` (\`workflowId\`)`, ); } } diff --git a/packages/cli/src/databases/migrations/mysqldb/1652905585850-AddAPIKeyColumn.ts b/packages/cli/src/databases/migrations/mysqldb/1652905585850-AddAPIKeyColumn.ts index a527b321e01bc..58d476199f136 100644 --- a/packages/cli/src/databases/migrations/mysqldb/1652905585850-AddAPIKeyColumn.ts +++ b/packages/cli/src/databases/migrations/mysqldb/1652905585850-AddAPIKeyColumn.ts @@ -22,7 +22,7 @@ export class AddAPIKeyColumn1652905585850 implements MigrationInterface { public async down(queryRunner: QueryRunner): Promise { const tablePrefix = config.get('database.tablePrefix'); await queryRunner.query( - 'DROP INDEX `IDX_81fc04c8a17de15835713505e4` ON `' + tablePrefix + 'execution_entity`', + `DROP INDEX \`UQ_${tablePrefix}ie0zomxves9w3p774drfrkxtj5\` ON \`${tablePrefix}user\``, ); await queryRunner.query('ALTER TABLE `' + tablePrefix + 'user` DROP COLUMN `apiKey`'); }