Skip to content

Commit

Permalink
fix awaiting rollback function
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Jun 20, 2023
1 parent 7fe9d35 commit f72c71b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kontent-ai/cli",
"version": "0.7.3",
"version": "0.7.4",
"description": "Command line interface tool that can be used for generating and runningKontent.ai migration scripts",
"main": "./lib/index.js",
"types": "./lib/types/index.d.ts",
Expand Down
11 changes: 5 additions & 6 deletions src/utils/migrationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ export const runMigration = async (migrationsStatus: IStatus, migration: IMigrat

try {
if (operation === 'run') {
await migration.module.run(client).then(async () => {
await markAsCompleted(migrationsStatus, projectId, migration.name, migration.module.order, operation, saveStatusFromPlugin);
});
await migration.module.run(client);
await markAsCompleted(migrationsStatus, projectId, migration.name, migration.module.order, operation, saveStatusFromPlugin);
} else {
if (!migration.module.rollback) {
throw new Error('No rollback function specified');
}
migration.module.rollback?.(client).then(async () => {
await markAsCompleted(migrationsStatus, projectId, migration.name, migration.module.order, operation, saveStatusFromPlugin);
});

await migration.module.rollback(client);
await markAsCompleted(migrationsStatus, projectId, migration.name, migration.module.order, operation, saveStatusFromPlugin);
}
} catch (e) {
console.error(chalk.redBright('An error occurred while running migration:'), chalk.yellowBright(migration.name), chalk.redBright('see the output from running the script.'));
Expand Down

0 comments on commit f72c71b

Please sign in to comment.