Skip to content

Commit

Permalink
use snake_case instead of camelCase with updateOnDuplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksTeresh committed Jun 13, 2024
1 parent 0915974 commit ca4fdff
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion importer-mankeli/src/messageHandlers/assessmentItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ const parseAssessmentItem = assessmentItem => {
// ^ yes, assessment items are snapshot data ¯\_(ツ)_/¯
module.exports = async ({ active, deleted }, transaction) => {
const parsedAssessmentItems = [...active, ...deleted].map(parseAssessmentItem)
await bulkCreate(AssessmentItem, parsedAssessmentItems, transaction, ['id', 'modificationOrdinal', 'autoId'])
await bulkCreate(AssessmentItem, parsedAssessmentItems, transaction, ['id', 'modification_ordinal', 'auto_id'])
}
2 changes: 1 addition & 1 deletion importer-mankeli/src/messageHandlers/organisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ const parseOrganisation = organisation => {
// the db in a similar fashion as studyrights.
module.exports = async ({ active, deleted }, transaction) => {
const parsedOrganisations = [...active, ...deleted].map(parseOrganisation)
await bulkCreate(Organisation, parsedOrganisations, transaction, ['id', 'modificationOrdinal', 'autoId'])
await bulkCreate(Organisation, parsedOrganisations, transaction, ['id', 'modification_ordinal', 'auto_id'])
}
2 changes: 1 addition & 1 deletion importer-mankeli/src/messageHandlers/studyRight.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ const parseStudyRight = studyRight => {
// eslint-disable-next-line
module.exports = async ({ active, deleted }, transaction) => {
const parsedStudyRights = [...active, ...deleted].map(parseStudyRight)
await bulkCreate(StudyRight, parsedStudyRights, transaction, ['id', 'modificationOrdinal', 'autoId'])
await bulkCreate(StudyRight, parsedStudyRights, transaction, ['id', 'modification_ordinal', 'auto_id'])
}
7 changes: 2 additions & 5 deletions importer-mankeli/src/utils/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ const bulkCreate = async (model, entities, transaction, properties = ['id']) =>
try {
await model.bulkCreate(entities, {
updateOnDuplicate: getColumnsToUpdate(model, properties),
transaction,
logging: logger.info
transaction
})
} catch (error) {
logger.info(getColumnsToUpdate(model, properties))
logger.error(error)
// If one fails on bulkCreate, re-do them individually and report the individual failures.
for (const entity of entities) {
try {
await model.upsert(entity, {
updateOnDuplicate: getColumnsToUpdate(model, properties),
transaction,
logging: logger.info
transaction
})
} catch (e) {
logger.error(e)
Expand Down

0 comments on commit ca4fdff

Please sign in to comment.