From 5a14d92c3ae840383505f91f5187dcdb71c65e3f Mon Sep 17 00:00:00 2001 From: mck Date: Thu, 23 Nov 2017 21:31:39 +1100 Subject: [PATCH] Duplicate the Migration009 script so it can run again to fix missing RepairSegment startTimes --- .../storage/cassandra/Migration011.java | 32 +++++++++++++++++++ .../db/cassandra/011_fix_start_times.cql | 4 +++ .../h2/V6_0_0__fix_repair_segment_table.sql | 10 ++++++ .../V6_0_0__fix_repair_segment_table.sql | 10 ++++++ 4 files changed, 56 insertions(+) create mode 100644 src/server/src/main/java/io/cassandrareaper/storage/cassandra/Migration011.java create mode 100644 src/server/src/main/resources/db/cassandra/011_fix_start_times.cql create mode 100644 src/server/src/main/resources/db/h2/V6_0_0__fix_repair_segment_table.sql create mode 100644 src/server/src/main/resources/db/postgres/V6_0_0__fix_repair_segment_table.sql diff --git a/src/server/src/main/java/io/cassandrareaper/storage/cassandra/Migration011.java b/src/server/src/main/java/io/cassandrareaper/storage/cassandra/Migration011.java new file mode 100644 index 000000000..fa1bab5fa --- /dev/null +++ b/src/server/src/main/java/io/cassandrareaper/storage/cassandra/Migration011.java @@ -0,0 +1,32 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.cassandrareaper.storage.cassandra; + + +import com.datastax.driver.core.Session; + +public final class Migration011 { + + private Migration011() { + } + + /** + * fix segment start and end times in the repair_run table. + * delegates to Migration009 as that does everything already. + */ + public static void migrate(Session session) { + Migration009.migrate(session); + } +} diff --git a/src/server/src/main/resources/db/cassandra/011_fix_start_times.cql b/src/server/src/main/resources/db/cassandra/011_fix_start_times.cql new file mode 100644 index 000000000..ed7fd9b46 --- /dev/null +++ b/src/server/src/main/resources/db/cassandra/011_fix_start_times.cql @@ -0,0 +1,4 @@ +-- +-- Intentionally blank +-- +-- Placeholder for Migration011 \ No newline at end of file diff --git a/src/server/src/main/resources/db/h2/V6_0_0__fix_repair_segment_table.sql b/src/server/src/main/resources/db/h2/V6_0_0__fix_repair_segment_table.sql new file mode 100644 index 000000000..ea680f674 --- /dev/null +++ b/src/server/src/main/resources/db/h2/V6_0_0__fix_repair_segment_table.sql @@ -0,0 +1,10 @@ +-- +-- fix segment start and end times in the repair_run table +-- + +UPDATE repair_segment +SET start_time = end_time +WHERE start_time is NULL +AND end_time IS NOT NULL; + + diff --git a/src/server/src/main/resources/db/postgres/V6_0_0__fix_repair_segment_table.sql b/src/server/src/main/resources/db/postgres/V6_0_0__fix_repair_segment_table.sql new file mode 100644 index 000000000..ea680f674 --- /dev/null +++ b/src/server/src/main/resources/db/postgres/V6_0_0__fix_repair_segment_table.sql @@ -0,0 +1,10 @@ +-- +-- fix segment start and end times in the repair_run table +-- + +UPDATE repair_segment +SET start_time = end_time +WHERE start_time is NULL +AND end_time IS NOT NULL; + +