From f943732f1346d9c8941a260b4457e1dfbaa40b0d Mon Sep 17 00:00:00 2001 From: dominicwest <dominic.west@cabinetoffice.gov.uk> Date: Tue, 2 Apr 2024 11:26:00 +0100 Subject: [PATCH 1/6] GAP-2533: Retrospectively fix BST ads in prod --- .../migration/V1_101__retrospectively_fix_bst_ads.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql diff --git a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql new file mode 100644 index 00000000..83948168 --- /dev/null +++ b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql @@ -0,0 +1,11 @@ +UPDATE grant_advert + SET opening_date = opening_date - INTERVAL '1 hour' +WHERE to_char(opening_date, 'TZ') = 'BST' + AND created > '2023-09-28'::DATE + AND status = 'SCHEDULED'; + +UPDATE grant_advert + SET closing_date = closing_date - INTERVAL '1 hour' +WHERE to_char(closing_date, 'TZ') = 'BST' + AND created > '2023-09-28'::DATE + AND status = 'PUBLISHED'; \ No newline at end of file From 502b4897ac15c3d1a2c69c3401efdbfdcb95a3e4 Mon Sep 17 00:00:00 2001 From: dominicwest <dominic.west@cabinetoffice.gov.uk> Date: Tue, 2 Apr 2024 11:31:02 +0100 Subject: [PATCH 2/6] GAP-2533: Including release time --- .../db/migration/V1_101__retrospectively_fix_bst_ads.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql index 83948168..4ba73601 100644 --- a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql +++ b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql @@ -1,11 +1,11 @@ UPDATE grant_advert SET opening_date = opening_date - INTERVAL '1 hour' WHERE to_char(opening_date, 'TZ') = 'BST' - AND created > '2023-09-28'::DATE + AND created > '2023-09-28 12:00:00'::TIMESTAMP AND status = 'SCHEDULED'; UPDATE grant_advert SET closing_date = closing_date - INTERVAL '1 hour' WHERE to_char(closing_date, 'TZ') = 'BST' - AND created > '2023-09-28'::DATE + AND created > '2023-09-28 12:00:00'::TIMESTAMP AND status = 'PUBLISHED'; \ No newline at end of file From 8b87271f4e09cc0e27d8a6a76eced97df7aa6130 Mon Sep 17 00:00:00 2001 From: dominicwest <dominic.west@cabinetoffice.gov.uk> Date: Tue, 2 Apr 2024 12:11:25 +0100 Subject: [PATCH 3/6] GAP-2533: Overriding UTC opening/closing dates as Europe/London time --- .../migration/V1_101__retrospectively_fix_bst_ads.sql | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql index 4ba73601..d9caf347 100644 --- a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql +++ b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql @@ -1,11 +1,9 @@ UPDATE grant_advert - SET opening_date = opening_date - INTERVAL '1 hour' -WHERE to_char(opening_date, 'TZ') = 'BST' - AND created > '2023-09-28 12:00:00'::TIMESTAMP + SET opening_date = opening_date AT TIME ZONE 'Europe/London' +WHERE created > '2023-09-28 12:00:00'::TIMESTAMP AND status = 'SCHEDULED'; UPDATE grant_advert - SET closing_date = closing_date - INTERVAL '1 hour' -WHERE to_char(closing_date, 'TZ') = 'BST' - AND created > '2023-09-28 12:00:00'::TIMESTAMP + SET closing_date = closing_date AT TIME ZONE 'Europe/London' +WHERE created > '2023-09-28 12:00:00'::TIMESTAMP AND status = 'PUBLISHED'; \ No newline at end of file From 28d80c00b3f65b582e7cb9613bb7d18cf7a31ff8 Mon Sep 17 00:00:00 2001 From: dominicwest <dominic.west@cabinetoffice.gov.uk> Date: Tue, 2 Apr 2024 12:13:35 +0100 Subject: [PATCH 4/6] GAP-2533: Update scheduled closing times too --- .../db/migration/V1_101__retrospectively_fix_bst_ads.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql index d9caf347..4335a0d8 100644 --- a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql +++ b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql @@ -6,4 +6,4 @@ WHERE created > '2023-09-28 12:00:00'::TIMESTAMP UPDATE grant_advert SET closing_date = closing_date AT TIME ZONE 'Europe/London' WHERE created > '2023-09-28 12:00:00'::TIMESTAMP - AND status = 'PUBLISHED'; \ No newline at end of file + AND (status = 'PUBLISHED' OR status = 'SCHEDULED';) \ No newline at end of file From a1cc70066d695422f6bc8a5f3a5ee9c404f1c631 Mon Sep 17 00:00:00 2001 From: dominicwest <dominic.west@cabinetoffice.gov.uk> Date: Tue, 2 Apr 2024 12:16:39 +0100 Subject: [PATCH 5/6] GAP-2533: Fix syntax --- .../db/migration/V1_101__retrospectively_fix_bst_ads.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql index 4335a0d8..1b75f12d 100644 --- a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql +++ b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql @@ -6,4 +6,4 @@ WHERE created > '2023-09-28 12:00:00'::TIMESTAMP UPDATE grant_advert SET closing_date = closing_date AT TIME ZONE 'Europe/London' WHERE created > '2023-09-28 12:00:00'::TIMESTAMP - AND (status = 'PUBLISHED' OR status = 'SCHEDULED';) \ No newline at end of file + AND (status = 'PUBLISHED' OR status = 'SCHEDULED'); \ No newline at end of file From dc05e73591087086f74b482953cf3e21d010fdd1 Mon Sep 17 00:00:00 2001 From: dominicwest <dominic.west@cabinetoffice.gov.uk> Date: Tue, 2 Apr 2024 12:32:14 +0100 Subject: [PATCH 6/6] GAP-2533: Hard code datetimes for BST --- .../V1_101__retrospectively_fix_bst_ads.sql | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql index 1b75f12d..a593eac1 100644 --- a/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql +++ b/src/main/resources/db/migration/V1_101__retrospectively_fix_bst_ads.sql @@ -1,9 +1,13 @@ UPDATE grant_advert - SET opening_date = opening_date AT TIME ZONE 'Europe/London' -WHERE created > '2023-09-28 12:00:00'::TIMESTAMP - AND status = 'SCHEDULED'; + SET opening_date = opening_date - INTERVAL '1 hour' +WHERE opening_date > '2024-03-31 01:00:00'::TIMESTAMP + AND opening_date < '2024-10-27 02:00:00'::TIMESTAMP + AND created > '2023-09-28 12:00:00'::TIMESTAMP + AND status = 'SCHEDULED'; UPDATE grant_advert - SET closing_date = closing_date AT TIME ZONE 'Europe/London' -WHERE created > '2023-09-28 12:00:00'::TIMESTAMP - AND (status = 'PUBLISHED' OR status = 'SCHEDULED'); \ No newline at end of file + SET closing_date = closing_date - INTERVAL '1 hour' +WHERE closing_date > '2024-03-31 01:00:00'::TIMESTAMP + AND closing_date < '2024-10-27 02:00:00'::TIMESTAMP + AND created > '2023-09-28 12:00:00'::TIMESTAMP + AND (status = 'PUBLISHED' OR status = 'SCHEDULED'); \ No newline at end of file