From 7a491f715627c484120758cc7e145937ab351fc8 Mon Sep 17 00:00:00 2001 From: Andreia Pena Date: Mon, 16 Sep 2024 17:25:14 +0200 Subject: [PATCH] :sparkles: api: adding a column to register candidate reconciliation Co-authored-by: Andreia Pena --- .../factory/build-certification-candidate.js | 3 +++ ...liatedAt-on-certification-candidates-table.js | 16 ++++++++++++++++ .../repositories/candidate-repository_test.js | 1 + 3 files changed, 20 insertions(+) create mode 100644 api/db/migrations/20240916152303_add-reconciliatedAt-on-certification-candidates-table.js diff --git a/api/db/database-builder/factory/build-certification-candidate.js b/api/db/database-builder/factory/build-certification-candidate.js index 062c2ed0423..0242d112d02 100644 --- a/api/db/database-builder/factory/build-certification-candidate.js +++ b/api/db/database-builder/factory/build-certification-candidate.js @@ -28,6 +28,7 @@ const buildCertificationCandidate = function ({ prepaymentCode = null, hasSeenCertificationInstructions = false, accessibilityAdjustmentNeeded = false, + reconciliatedAt = null, } = {}) { sessionId = _.isUndefined(sessionId) ? buildSession().id : sessionId; userId = _.isUndefined(userId) ? buildUser().id : userId; @@ -56,6 +57,7 @@ const buildCertificationCandidate = function ({ prepaymentCode, hasSeenCertificationInstructions, accessibilityAdjustmentNeeded, + reconciliatedAt, }; databaseBuffer.pushInsertable({ @@ -87,6 +89,7 @@ const buildCertificationCandidate = function ({ prepaymentCode, hasSeenCertificationInstructions, accessibilityAdjustmentNeeded, + reconciliatedAt, }; }; diff --git a/api/db/migrations/20240916152303_add-reconciliatedAt-on-certification-candidates-table.js b/api/db/migrations/20240916152303_add-reconciliatedAt-on-certification-candidates-table.js new file mode 100644 index 00000000000..d5b58b20e40 --- /dev/null +++ b/api/db/migrations/20240916152303_add-reconciliatedAt-on-certification-candidates-table.js @@ -0,0 +1,16 @@ +const TABLE_NAME = 'certification-candidates'; +const COLUMN_NAME = 'reconciliatedAt'; + +const up = async function (knex) { + await knex.schema.table(TABLE_NAME, function (table) { + table.dateTime(COLUMN_NAME).nullable().defaultTo(null); + }); +}; + +const down = async function (knex) { + await knex.schema.table(TABLE_NAME, function (table) { + table.dropColumn(COLUMN_NAME); + }); +}; + +export { down, up }; diff --git a/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js b/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js index 2102fde91df..60aee6ff82f 100644 --- a/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js +++ b/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js @@ -279,6 +279,7 @@ describe('Integration | Certification | Session | Repository | Candidate', funct complementaryCertificationKey: 'Chose', }, ], + reconciliatedAt: null, }; databaseBuilder.factory.buildSession({ id: candidateData.sessionId }); databaseBuilder.factory.buildComplementaryCertification({ id: 22, label: 'Quelque', key: 'Chose' });