refactor(core): Delete boilerplate code across migrations (no-changelog) (#5254)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-05-05 09:28:59 +00:00
committed by GitHub
parent d5c44987f4
commit 82fe6383ef
122 changed files with 879 additions and 1844 deletions

View File

@@ -1,19 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { getTablePrefix, runInBatches } from '@db/utils/migrationHelpers';
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import type { MigrationContext, ReversibleMigration } from '@db/types';
import { runInBatches } from '@db/utils/migrationHelpers';
// replacing the credentials in workflows and execution
// `nodeType: name` changes to `nodeType: { id, name }`
export class UpdateWorkflowCredentials1630419189837 implements MigrationInterface {
name = 'UpdateWorkflowCredentials1630419189837';
public async up(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = getTablePrefix();
const credentialsEntities = await queryRunner.query(`
export class UpdateWorkflowCredentials1630419189837 implements ReversibleMigration {
async up({ queryRunner, tablePrefix }: MigrationContext) {
const credentialsEntities = (await queryRunner.query(`
SELECT id, name, type
FROM ${tablePrefix}credentials_entity
`);
`)) as Array<{ id: string; name: string; type: string }>;
const workflowsQuery = `
SELECT id, nodes
@@ -53,7 +55,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
{},
);
queryRunner.query(updateQuery, updateParams);
await queryRunner.query(updateQuery, updateParams);
}
});
});
@@ -96,7 +98,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
{},
);
queryRunner.query(updateQuery, updateParams);
await queryRunner.query(updateQuery, updateParams);
}
});
});
@@ -141,18 +143,16 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
{},
);
queryRunner.query(updateQuery, updateParams);
await queryRunner.query(updateQuery, updateParams);
}
});
}
public async down(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = getTablePrefix();
const credentialsEntities = await queryRunner.query(`
async down({ queryRunner, tablePrefix }: MigrationContext) {
const credentialsEntities = (await queryRunner.query(`
SELECT id, name, type
FROM ${tablePrefix}credentials_entity
`);
`)) as Array<{ id: string; name: string; type: string }>;
const workflowsQuery = `
SELECT id, nodes
@@ -197,7 +197,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
{},
);
queryRunner.query(updateQuery, updateParams);
await queryRunner.query(updateQuery, updateParams);
}
});
});
@@ -246,7 +246,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
{},
);
queryRunner.query(updateQuery, updateParams);
await queryRunner.query(updateQuery, updateParams);
}
});
});
@@ -295,7 +295,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
{},
);
queryRunner.query(updateQuery, updateParams);
await queryRunner.query(updateQuery, updateParams);
}
});
}