-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(migration): introduce conditionality and continue indexing on failure #7742
Conversation
Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:
|
Your environment is deployed to https://fixmigration-errors.opencrvs.dev |
@@ -67,7 +67,7 @@ export const up = async (db: Db, client: MongoClient) => { | |||
const operationHistoriesData = | |||
searchResult && | |||
searchResult.body.hits.hits.length > 0 && | |||
searchResult.body.hits.hits[0]._source?.operationHistories | |||
searchResult.body.hits.hits?.[0]?._source?.operationHistories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this is safer instead of the three lines here?
searchResult?.body?.hits?.hits?.[0]?._source?.operationHistories
@@ -150,10 +151,10 @@ async function updateEventLocationIdOrJurisdictionIds(db: Db, elasticDoc: any) { | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be similar to packages/migration/src/migrations/hearth/20221110092434-add_identifiers_DOB_gender_location.ts
?
@@ -150,10 +151,10 @@ async function updateEventLocationIdOrJurisdictionIds(db: Db, elasticDoc: any) { | |||
) | |||
|
|||
if (locationDoc.length > 0) { | |||
if (locationDoc[0].type.coding[0].code === 'HEALTH_FACILITY') { | |||
body.eventLocationId = locationDoc[0].id | |||
if (locationDoc?.[0]?.type?.coding?.[0]?.code === 'HEALTH_FACILITY') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (locationDoc?.[0]?.type?.coding?.[0]?.code === 'HEALTH_FACILITY') { | |
if (locationDoc[0].type?.coding?.[0]?.code === 'HEALTH_FACILITY') { |
as we just asserted that length is greater than zero 😄
🍒 Merge changes from PR #7742 to release-v1.6.0
Issue:
When running migrations, we assume arrays always contain at least one item. This results to failure during the process.
Fix:
Introduce conditional checks to remaining files, even if they might work without 99% of the time.
Issue:
Reindexing throws an error when single document fails to be indexed to elasticsearch.
Most likely the implicit schema that gets created prevents some of the items being added.
Fix:
Allow elasticsearch to drop the documents but keep track of them.