Fix custom object requests pending (#2240)

* Fix custom object requests pending

* fix typo
This commit is contained in:
Weiko
2023-10-26 12:20:03 +02:00
committed by GitHub
parent c335d19c97
commit 781a1de8f4
2 changed files with 13 additions and 5 deletions

View File

@ -45,19 +45,20 @@ export class MigrationRunnerService {
// Loop over each migration and create or update the table // Loop over each migration and create or update the table
// TODO: Should be done in a transaction // TODO: Should be done in a transaction
for (const migration of flattenedPendingMigrations) { for (const migration of flattenedPendingMigrations) {
await this.handleTableChanges(queryRunner, schemaName, migration); await this.handleTableChanges(queryRunner, schemaName, migration);
} }
// Update appliedAt date for each migration // Update appliedAt date for each migration
// TODO: Should be done after the migration is successful // TODO: Should be done after the migration is successful
pendingMigrations.forEach(async (pendingMigration) => { for (const pendingMigration of pendingMigrations) {
await this.tenantMigrationService.setAppliedAtForMigration( await this.tenantMigrationService.setAppliedAtForMigration(
workspaceId, workspaceId,
pendingMigration, pendingMigration,
); );
}); }
await queryRunner.release();
return flattenedPendingMigrations; return flattenedPendingMigrations;
} }
@ -188,6 +189,13 @@ export class MigrationRunnerService {
tableName: string, tableName: string,
migrationColumn: TenantMigrationColumnAction, migrationColumn: TenantMigrationColumnAction,
) { ) {
const hasColumn = await queryRunner.hasColumn(
`${schemaName}.${tableName}`,
migrationColumn.name,
);
if (hasColumn) {
return;
}
await queryRunner.addColumn( await queryRunner.addColumn(
`${schemaName}.${tableName}`, `${schemaName}.${tableName}`,
new TableColumn({ new TableColumn({

View File

@ -107,7 +107,7 @@ export class TenantInitialisationService {
dataSourceMetadata.id, dataSourceMetadata.id,
); );
const worksapceDataSource = const workspaceDataSource =
await this.dataSourceService.connectToWorkspaceDataSource(workspaceId); await this.dataSourceService.connectToWorkspaceDataSource(workspaceId);
for (const object of objects) { for (const object of objects) {
@ -123,7 +123,7 @@ export class TenantInitialisationService {
Object.values(field.targetColumnMap), Object.values(field.targetColumnMap),
); );
worksapceDataSource await workspaceDataSource
?.createQueryBuilder() ?.createQueryBuilder()
.insert() .insert()
.into(`${dataSourceMetadata.schema}.${object.targetTableName}`, columns) .into(`${dataSourceMetadata.schema}.${object.targetTableName}`, columns)