Improve add field to view script to handle errors (#6232)
Adding logs and catching errors to continue not to block the script execution if the command fails for one workspace
This commit is contained in:
@ -80,6 +80,8 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends
|
||||
}
|
||||
|
||||
for (const workspaceId of workspaceIds) {
|
||||
this.logger.log(`Running command for workspace ${workspaceId}`);
|
||||
try {
|
||||
const viewFieldRepository =
|
||||
await this.twentyORMManager.getRepositoryForWorkspace(
|
||||
workspaceId,
|
||||
@ -96,7 +98,6 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends
|
||||
await this.typeORMService.connectToDataSource(dataSourceMetadata);
|
||||
|
||||
if (workspaceDataSource) {
|
||||
try {
|
||||
const newAddressField = await this.fieldMetadataRepository.findBy({
|
||||
workspaceId,
|
||||
standardId: newFieldStandardId,
|
||||
@ -156,12 +157,6 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends
|
||||
`New address field successfully added to view ${viewId} for workspace ${workspaceId}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.log(
|
||||
chalk.red(`Running command on workspace ${workspaceId} failed`),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,8 +165,16 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends
|
||||
this.logger.log(
|
||||
chalk.green(`Running command on workspace ${workspaceId} done`),
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.log(
|
||||
chalk.red(
|
||||
`Running command on workspace ${workspaceId} failed with error: ${error}`,
|
||||
),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.logger.log(chalk.green(`Command completed!`));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user