Fix custom object requests pending (#2240)
* Fix custom object requests pending * fix typo
This commit is contained in:
@ -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({
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user