From ea4d7d7603180a85cc6be21e597e8f8ecf91c628 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Fri, 16 Aug 2024 16:37:39 +0100 Subject: [PATCH 1/4] Rename mod_log field in version views https://eaflood.atlassian.net/browse/WATER-4565 > Part of the work to display a licence's history to users (mod log) In [Add mod_log field to return versions view](https://github.com/DEFRA/water-abstraction-system/pull/1252), we added a migration to add the new `mod_log` field to the charge, licence, and return version views. This field was intended to hold details from the linked NALD mod log record, such as who, when, and why the version was created. However, we've since learned that a version in NALD can have multiple mod log records. Therefore, we want to change the name to `mod_logs` to make that clear. Because the previous migrations have not yet been released, we'll update them rather than add new ones. We also overlooked telling Objection.js that the field is JSON in the models. So, we do that as part of this change as well. From 2da1a9fbaba24addcc0bf84f06f7cd3edf41f7a2 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Fri, 16 Aug 2024 17:01:08 +0100 Subject: [PATCH 2/4] Housekeeping - rename legacy notes migration This just brings it inline with the other legacy migrations. We should have spotted it at the time. --- ...0240807142828_water-notes.js => 20221108007037_water-notes.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/migrations/legacy/{20240807142828_water-notes.js => 20221108007037_water-notes.js} (100%) diff --git a/db/migrations/legacy/20240807142828_water-notes.js b/db/migrations/legacy/20221108007037_water-notes.js similarity index 100% rename from db/migrations/legacy/20240807142828_water-notes.js rename to db/migrations/legacy/20221108007037_water-notes.js From 87926853d293997cd5ef4f4db746d756d26f6384 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Sun, 18 Aug 2024 10:07:27 +0100 Subject: [PATCH 3/4] Delete the migration --- ...240809164102_alter-return-versions-view.js | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 db/migrations/public/20240809164102_alter-return-versions-view.js diff --git a/db/migrations/public/20240809164102_alter-return-versions-view.js b/db/migrations/public/20240809164102_alter-return-versions-view.js deleted file mode 100644 index 23b4dadc75..0000000000 --- a/db/migrations/public/20240809164102_alter-return-versions-view.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict' - -const viewName = 'return_versions' - -exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('return_versions').withSchema('water').select([ - 'return_version_id AS id', - 'licence_id', - 'version_number AS version', - 'start_date', - 'end_date', - 'status', - 'external_id', - 'reason', - 'multiple_upload', - 'notes', - 'created_by', - 'mod_log', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) -} - -exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('return_versions').withSchema('water').select([ - 'return_version_id AS id', - 'licence_id', - 'version_number AS version', - 'start_date', - 'end_date', - 'status', - 'external_id', - 'reason', - 'multiple_upload', - 'notes', - 'created_by', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) -} From ac2217e0403e4a103b2b6a03dd87926a5f87b13f Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Sun, 18 Aug 2024 10:13:02 +0100 Subject: [PATCH 4/4] Revert legacy migration change --- db/migrations/legacy/20221108007023_water-return-versions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/db/migrations/legacy/20221108007023_water-return-versions.js b/db/migrations/legacy/20221108007023_water-return-versions.js index e477186470..6db865a83a 100644 --- a/db/migrations/legacy/20221108007023_water-return-versions.js +++ b/db/migrations/legacy/20221108007023_water-return-versions.js @@ -21,7 +21,6 @@ exports.up = function (knex) { table.boolean('multiple_upload').notNullable().defaultTo(false) table.text('notes') table.integer('created_by') - table.jsonb('mod_log').notNullable().defaultTo({}) // Legacy timestamps table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now())