From e366dcc98faffc158cff34a6f27743166441fa7e Mon Sep 17 00:00:00 2001 From: James Renken Date: Fri, 10 Jan 2025 22:43:47 -0800 Subject: [PATCH 1/3] Stop using LockCol in registrations table Alter the `LockCol` column to be nullable, so that we can stop using it. --- sa/database.go | 1 - .../20250110000000_NullRegistrationsLockCol.sql | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql diff --git a/sa/database.go b/sa/database.go index 5b516d1ebb5..886f4dbd994 100644 --- a/sa/database.go +++ b/sa/database.go @@ -265,7 +265,6 @@ func (log *SQLLogger) Printf(format string, v ...interface{}) { func initTables(dbMap *borp.DbMap) { regTable := dbMap.AddTableWithName(regModel{}, "registrations").SetKeys(true, "ID") - regTable.SetVersionCol("LockCol") regTable.ColMap("Key").SetNotNull(true) regTable.ColMap("KeySHA256").SetNotNull(true).SetUnique(true) dbMap.AddTableWithName(issuedNameModel{}, "issuedNames").SetKeys(true, "ID") diff --git a/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql b/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql new file mode 100644 index 00000000000..53b57458f69 --- /dev/null +++ b/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql @@ -0,0 +1,10 @@ + +-- +migrate Up +-- SQL in section 'Up' is executed when this migration is applied + +ALTER TABLE `registrations` ALTER COLUMN `LockCol` BIGINT(20) DEFAULT 0; + +-- +migrate Down +-- SQL section 'Down' is executed when this migration is rolled back + +ALTER TABLE `registrations` ALTER COLUMN `LockCol` BIGINT(20) NOT NULL; From 2920875b4f0138e4e810bf5d2b6889b3e9ebd438 Mon Sep 17 00:00:00 2001 From: James Renken Date: Fri, 10 Jan 2025 22:59:30 -0800 Subject: [PATCH 2/3] Fix MariaDB syntax --- .../boulder_sa/20250110000000_NullRegistrationsLockCol.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql b/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql index 53b57458f69..035af83208a 100644 --- a/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql +++ b/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql @@ -2,9 +2,9 @@ -- +migrate Up -- SQL in section 'Up' is executed when this migration is applied -ALTER TABLE `registrations` ALTER COLUMN `LockCol` BIGINT(20) DEFAULT 0; +ALTER TABLE `registrations` MODIFY COLUMN `LockCol` BIGINT(20) DEFAULT 0; -- +migrate Down -- SQL section 'Down' is executed when this migration is rolled back -ALTER TABLE `registrations` ALTER COLUMN `LockCol` BIGINT(20) NOT NULL; +ALTER TABLE `registrations` MODIFY COLUMN `LockCol` BIGINT(20) NOT NULL; From 857edbfb510e21feda324d392a88039328c75707 Mon Sep 17 00:00:00 2001 From: James Renken Date: Fri, 10 Jan 2025 23:01:28 -0800 Subject: [PATCH 3/3] Set a default value instead for a faster ALTER --- .../boulder_sa/20250110000000_NullRegistrationsLockCol.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql b/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql index 035af83208a..af0170406c0 100644 --- a/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql +++ b/sa/db-next/boulder_sa/20250110000000_NullRegistrationsLockCol.sql @@ -2,9 +2,9 @@ -- +migrate Up -- SQL in section 'Up' is executed when this migration is applied -ALTER TABLE `registrations` MODIFY COLUMN `LockCol` BIGINT(20) DEFAULT 0; +ALTER TABLE `registrations` ALTER COLUMN `LockCol` SET DEFAULT 0; -- +migrate Down -- SQL section 'Down' is executed when this migration is rolled back -ALTER TABLE `registrations` MODIFY COLUMN `LockCol` BIGINT(20) NOT NULL; +ALTER TABLE `registrations` ALTER COLUMN `LockCol` DROP DEFAULT;