-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] ajoute la configuration de l'import sco fwb (Pix-12759)
- Loading branch information
Showing
2 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
api/db/migrations/20240708100245_add-fwb-organization-learner-import-format.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const engineeringUserId = process.env.ENGINEERING_USER_ID; | ||
const importFormatName = 'SCO-FWB'; | ||
|
||
const up = async function (knex) { | ||
//Avoid fail migration when engineering user does not exist. | ||
if (!engineeringUserId) return; | ||
const user = await knex | ||
.from('users') | ||
.where({ id: parseInt(engineeringUserId) }) | ||
.first(); | ||
if (!user) return; | ||
await knex('organization-learner-import-formats').insert({ | ||
name: importFormatName, | ||
fileType: 'csv', | ||
config: { | ||
acceptedEncoding: ['utf8'], | ||
unicityColumns: ['Nom', 'Prénom', 'Date de naissance (jj/mm/aaaa)'], | ||
reconciliationMappingColumns: [ | ||
{ key: 'reconcileField1', columnName: 'Nom' }, | ||
{ key: 'reconcileField2', columnName: 'Prénom' }, | ||
{ key: 'reconcileField3', columnName: 'Date de naissance (jj/mm/aaaa)' }, | ||
], | ||
validationRules: { | ||
formats: [ | ||
{ name: 'Nom', type: 'string', required: true }, | ||
{ name: 'Prénom', type: 'string', required: true }, | ||
{ name: 'Date de naissance (jj/mm/aaaa)', type: 'date', format: 'DD/MM/YYYY', required: true }, | ||
{ name: 'Classe', type: 'string', required: true }, | ||
], | ||
}, | ||
headers: [ | ||
{ name: 'Nom', property: 'lastName', required: true }, | ||
{ name: 'Prénom', property: 'firstName', required: true }, | ||
{ name: 'Date de naissance (jj/mm/aaaa)', required: true }, | ||
{ name: 'Classe', required: true }, | ||
], | ||
}, | ||
createdAt: new Date(), | ||
createdBy: parseInt(engineeringUserId), | ||
updatedAt: new Date(), | ||
}); | ||
}; | ||
|
||
const down = async function (knex) { | ||
await knex('organization-learner-import-formats').where({ name: importFormatName }).delete(); | ||
}; | ||
|
||
export { down, up }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters