From c87d352325ffd334e3dd8b0327c57b78b8864e03 Mon Sep 17 00:00:00 2001 From: martinboulais <31805063+martinboulais@users.noreply.github.com> Date: Thu, 12 Dec 2024 08:47:28 +0100 Subject: [PATCH 1/2] [O2B-1403] Simplify run time start and stop --- ...41212074001-create-rct-run-start-and-stop.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js diff --git a/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js b/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js new file mode 100644 index 0000000000..f7f22eafb5 --- /dev/null +++ b/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js @@ -0,0 +1,17 @@ +'use strict'; + +const ADD_RUN_RCT_START_AND_STOP = ` + ALTER TABLE runs + ADD COLUMN rct_time_start DATETIME(3) AS (COALESCE(first_tf_timestamp, time_trg_start, time_o2_start)) VIRTUAL AFTER time_start, + ADD COLUMN rct_time_end DATETIME(3) AS (COALESCE(last_tf_timestamp, time_trg_end, time_o2_end)) VIRTUAL AFTER rct_time_start; +`; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + up: async (queryInterface) => queryInterface.sequelize.query(ADD_RUN_RCT_START_AND_STOP), + + down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => { + await queryInterface.removeColumn('runs', 'rct_time_start', { transaction }); + await queryInterface.removeColumn('runs', 'rct_time_end', { transaction }); + }), +}; From 6e5dda2a5987a7ba5c97162b576e957256ce00d6 Mon Sep 17 00:00:00 2001 From: martinboulais <31805063+martinboulais@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:07:13 +0100 Subject: [PATCH 2/2] Rename rct to QC --- .../20241212074001-create-rct-run-start-and-stop.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js b/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js index f7f22eafb5..750400bae6 100644 --- a/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js +++ b/lib/database/migrations/20241212074001-create-rct-run-start-and-stop.js @@ -2,8 +2,8 @@ const ADD_RUN_RCT_START_AND_STOP = ` ALTER TABLE runs - ADD COLUMN rct_time_start DATETIME(3) AS (COALESCE(first_tf_timestamp, time_trg_start, time_o2_start)) VIRTUAL AFTER time_start, - ADD COLUMN rct_time_end DATETIME(3) AS (COALESCE(last_tf_timestamp, time_trg_end, time_o2_end)) VIRTUAL AFTER rct_time_start; + ADD COLUMN qc_time_start DATETIME(3) AS (COALESCE(first_tf_timestamp, time_trg_start, time_o2_start)) VIRTUAL AFTER time_start, + ADD COLUMN qc_time_end DATETIME(3) AS (COALESCE(last_tf_timestamp, time_trg_end, time_o2_end)) VIRTUAL AFTER qc_time_start; `; /** @type {import('sequelize-cli').Migration} */ @@ -11,7 +11,7 @@ module.exports = { up: async (queryInterface) => queryInterface.sequelize.query(ADD_RUN_RCT_START_AND_STOP), down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => { - await queryInterface.removeColumn('runs', 'rct_time_start', { transaction }); - await queryInterface.removeColumn('runs', 'rct_time_end', { transaction }); + await queryInterface.removeColumn('runs', 'qc_time_start', { transaction }); + await queryInterface.removeColumn('runs', 'qc_time_end', { transaction }); }), };