Skip to content

Commit

Permalink
CVSL-1613 Storing prison number against licence version (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrlee authored Feb 1, 2024
1 parent 4b58c1a commit 5e500c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions migrations/20240131160000_add-prison-number-to-licence-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.up = async function up(knex) {
await knex.schema.alterTable('licence_versions', (table) => {
table.string('prison_number', 7).nullable()
})
}

exports.down = async function down(knex) {
await knex.schema.alterTable('licence_versions', (table) => {
table.dropColumn('prison_number')
})
}
4 changes: 2 additions & 2 deletions server/data/licenceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export class LicenceClient {

saveApprovedLicenceVersion(bookingId, template) {
const query = {
text: `insert into licence_versions (booking_id, licence, version, vary_version, template)
select booking_id, licence, version, vary_version, $1
text: `insert into licence_versions (prison_number, booking_id, licence, version, vary_version, template)
select prison_number, booking_id, licence, version, vary_version, $1
from licences where booking_id = $2`,
values: [template, bookingId],
}
Expand Down
2 changes: 1 addition & 1 deletion test/data/licenceClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('licenceClient', () => {
describe('saveApprovedVersion', () => {
test('should pass in the correct sql', async () => {
const expectedVersionUpdate = 'insert into licence_versions'
const expectedSelect = 'select booking_id, licence, version, vary_version, $1'
const expectedSelect = 'select prison_number, booking_id, licence, version, vary_version, $1'
const expectedWhere = 'where booking_id = $2'

await licenceClient.saveApprovedLicenceVersion(BOOKING_ID, 'templateName')
Expand Down

0 comments on commit 5e500c1

Please sign in to comment.