@oliasoft-open-source/node-json-migrator 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8044,6 +8044,7 @@ const migrate = async ({
8044
8044
  };
8045
8045
  };
8046
8046
 
8047
+ const MAX_ATTEMPTS = 3;
8047
8048
  const migrateRecord = async ({
8048
8049
  record,
8049
8050
  config,
@@ -8133,14 +8134,24 @@ const migrateRecords = async ({
8133
8134
  if (recordList.length) {
8134
8135
  console.log(chalk.gray("Executing record migration scripts..."));
8135
8136
  for await (const record of recordList) {
8136
- const migrationErrorPayload = await migrateRecord({
8137
- record,
8138
- config,
8139
- beforeMigrateRecord,
8140
- afterMigrateRecord
8141
- });
8142
- if (migrationErrorPayload) {
8143
- migrationErrors.push(migrationErrorPayload);
8137
+ let attempt = 0;
8138
+ while (attempt < MAX_ATTEMPTS) {
8139
+ attempt += 1;
8140
+ if (attempt > 1) {
8141
+ console.log(chalk.gray("Retrying migration..."));
8142
+ }
8143
+ const migrationErrorPayload = await migrateRecord({
8144
+ record,
8145
+ config,
8146
+ beforeMigrateRecord,
8147
+ afterMigrateRecord
8148
+ });
8149
+ if (!migrationErrorPayload) {
8150
+ break;
8151
+ }
8152
+ if (migrationErrorPayload && attempt === MAX_ATTEMPTS) {
8153
+ migrationErrors.push(migrationErrorPayload);
8154
+ }
8144
8155
  }
8145
8156
  }
8146
8157
  }
package/dist/index.mjs CHANGED
@@ -8023,6 +8023,7 @@ const migrate = async ({
8023
8023
  };
8024
8024
  };
8025
8025
 
8026
+ const MAX_ATTEMPTS = 3;
8026
8027
  const migrateRecord = async ({
8027
8028
  record,
8028
8029
  config,
@@ -8112,14 +8113,24 @@ const migrateRecords = async ({
8112
8113
  if (recordList.length) {
8113
8114
  console.log(chalk.gray("Executing record migration scripts..."));
8114
8115
  for await (const record of recordList) {
8115
- const migrationErrorPayload = await migrateRecord({
8116
- record,
8117
- config,
8118
- beforeMigrateRecord,
8119
- afterMigrateRecord
8120
- });
8121
- if (migrationErrorPayload) {
8122
- migrationErrors.push(migrationErrorPayload);
8116
+ let attempt = 0;
8117
+ while (attempt < MAX_ATTEMPTS) {
8118
+ attempt += 1;
8119
+ if (attempt > 1) {
8120
+ console.log(chalk.gray("Retrying migration..."));
8121
+ }
8122
+ const migrationErrorPayload = await migrateRecord({
8123
+ record,
8124
+ config,
8125
+ beforeMigrateRecord,
8126
+ afterMigrateRecord
8127
+ });
8128
+ if (!migrationErrorPayload) {
8129
+ break;
8130
+ }
8131
+ if (migrationErrorPayload && attempt === MAX_ATTEMPTS) {
8132
+ migrationErrors.push(migrationErrorPayload);
8133
+ }
8123
8134
  }
8124
8135
  }
8125
8136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/node-json-migrator",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "A library for JSON migrations",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/node-postgresql-migrator",
6
6
  "bugs": {