Skip to content

Commit

Permalink
Fixed failing models migration (#3813)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kbirk and github-actions[bot] authored Jun 10, 2024
1 parent cb07855 commit f5cc32d
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,28 @@ Pair<Integer, Integer> migrateFromEsToPg(final ElasticsearchService elasticServi
continue;
}
if (asset.getId() == null || !asset.getId().toString().equals(hit.id())) {
asset.setId(UUID.fromString(hit.id()));
try {
asset.setId(UUID.fromString(hit.id()));
} catch (final Exception e) {
log.warn("Unable to parse id into UUID: {}, discarding doc", hit.id());
totalFailed++;
continue;
}
}
assets.add(asset);
}

if (!assets.isEmpty()) {
log.info("Saving {} rows to SQL...", assets.size());
long failed = 0;
for (final T asset : assets) {
try {
service.getRepository().save(asset);
totalSuccess++;
} catch (final Exception e) {
log.warn("Failed to insert id: {}", asset.getId(), e);
failed += 1;
totalFailed++;
}
}
if (failed == assets.size()) {
throw new RuntimeException("All assets failed to insert");
}
}

if (Objects.equals(lastId, lastPagesLastId) || assets.size() < PAGE_SIZE) {
Expand Down

0 comments on commit f5cc32d

Please sign in to comment.