From 80c33ee6fff99a8f8c24c63429bc875ea442ac0f Mon Sep 17 00:00:00 2001 From: Arjan H Date: Sat, 9 Dec 2023 14:55:33 +0100 Subject: [PATCH] Fix db migration to preserve existing data --- patch.sh | 1 + patches/db_migrations.patch | 12 ++++++------ patches/db_migrations2.patch | 13 +++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 patches/db_migrations2.patch diff --git a/patch.sh b/patch.sh index 6c6426a..38e48ed 100755 --- a/patch.sh +++ b/patch.sh @@ -29,6 +29,7 @@ $SUDO patch -p1 < $cloneDir/patches/contact-auditor_main.patch $SUDO patch -p1 < $cloneDir/patches/core_interfaces.patch $SUDO patch -p1 < $cloneDir/patches/crl-storer_main.patch $SUDO patch -p1 < $cloneDir/patches/db_migrations.patch +$SUDO patch -p1 < $cloneDir/patches/db_migrations2.patch $SUDO patch -p1 < $cloneDir/patches/errors_errors.patch $SUDO patch -p1 < $cloneDir/patches/expiration-mailer_main.patch $SUDO patch -p1 < $cloneDir/patches/linter_linter.patch diff --git a/patches/db_migrations.patch b/patches/db_migrations.patch index 313852d..6cc957d 100644 --- a/patches/db_migrations.patch +++ b/patches/db_migrations.patch @@ -1,5 +1,5 @@ diff --git a/sa/db/boulder_sa/20230419000000_CombinedSchema.sql b/sa/db/boulder_sa/20230419000000_CombinedSchema.sql -index 34d6f151c..1e065a7a6 100644 +index 34d6f151c..3641d1f7c 100644 --- a/sa/db/boulder_sa/20230419000000_CombinedSchema.sql +++ b/sa/db/boulder_sa/20230419000000_CombinedSchema.sql @@ -1,7 +1,9 @@ @@ -151,10 +151,10 @@ index 34d6f151c..1e065a7a6 100644 - PARTITION BY RANGE(id) -(PARTITION p_start VALUES LESS THAN (MAXVALUE)); +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ++ ++DROP TABLE IF EXISTS `orderToAuthz`; -CREATE TABLE `orderToAuthz2` ( -+DROP TABLE IF EXISTS `orderToAuthz`; -+ +CREATE TABLE IF NOT EXISTS `orderToAuthz2` ( `orderID` bigint(20) NOT NULL, `authzID` bigint(20) NOT NULL, @@ -217,7 +217,7 @@ index 34d6f151c..1e065a7a6 100644 -(PARTITION p_start VALUES LESS THAN (MAXVALUE)); +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + -+CREATE TABLE `revokedCertificates` ( ++CREATE TABLE IF NOT EXISTS `revokedCertificates` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `issuerID` bigint(20) NOT NULL, + `serial` varchar(255) NOT NULL, @@ -238,7 +238,7 @@ index 34d6f151c..1e065a7a6 100644 `id` bigint(20) NOT NULL AUTO_INCREMENT, `registrationID` bigint(20) NOT NULL, `serial` varchar(255) NOT NULL, -@@ -234,6 +237,18 @@ CREATE TABLE `serials` ( +@@ -234,6 +249,18 @@ CREATE TABLE `serials` ( -- First set of tables have foreign key constraints, so are dropped first. DROP TABLE `serials`; @@ -257,7 +257,7 @@ index 34d6f151c..1e065a7a6 100644 DROP TABLE `authz2`; DROP TABLE `blockedKeys`; DROP TABLE `certificateStatus`; -@@ -244,8 +259,44 @@ DROP TABLE `issuedNames`; +@@ -244,8 +271,44 @@ DROP TABLE `issuedNames`; DROP TABLE `keyHashToSerial`; DROP TABLE `newOrdersRL`; DROP TABLE `orderFqdnSets`; diff --git a/patches/db_migrations2.patch b/patches/db_migrations2.patch new file mode 100644 index 0000000..7aedebf --- /dev/null +++ b/patches/db_migrations2.patch @@ -0,0 +1,13 @@ +diff --git a/sa/db/boulder_sa/20230519000000_CrlShards.sql b/sa/db/boulder_sa/20230519000000_CrlShards.sql +index 6c0d0f9eb..8f4152299 100644 +--- a/sa/db/boulder_sa/20230519000000_CrlShards.sql ++++ b/sa/db/boulder_sa/20230519000000_CrlShards.sql +@@ -1,7 +1,7 @@ + -- +migrate Up + -- SQL in section 'Up' is executed when this migration is applied + +-CREATE TABLE `crlShards` ( ++CREATE TABLE IF NOT EXISTS `crlShards` ( + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, + `issuerID` bigint(20) NOT NULL, + `idx` int UNSIGNED NOT NULL,