diff --git a/nexus/db-model/src/schema_versions.rs b/nexus/db-model/src/schema_versions.rs index 5ceaf3167a6..cb5d244237e 100644 --- a/nexus/db-model/src/schema_versions.rs +++ b/nexus/db-model/src/schema_versions.rs @@ -17,7 +17,7 @@ use std::collections::BTreeMap; /// /// This must be updated when you change the database schema. Refer to /// schema/crdb/README.adoc in the root of this repository for details. -pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(65, 0, 0); +pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(66, 0, 0); /// List of all past database schema versions, in *reverse* order /// @@ -29,6 +29,7 @@ static KNOWN_VERSIONS: Lazy> = Lazy::new(|| { // | leaving the first copy as an example for the next person. // v // KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"), + KnownVersion::new(66, "add-instance-updater-lock"), KnownVersion::new(65, "region-replacement"), KnownVersion::new(64, "add-view-for-v2p-mappings"), KnownVersion::new(63, "remove-producer-base-route-column"), diff --git a/schema/crdb/add-instance-updater-lock/up.sql b/schema/crdb/add-instance-updater-lock/up.sql new file mode 100644 index 00000000000..76eae1f7231 --- /dev/null +++ b/schema/crdb/add-instance-updater-lock/up.sql @@ -0,0 +1,5 @@ +ALTER TABLE omicron.public.instance + ADD COLUMN IF NOT EXISTS updater_id UUID + DEFAULT null, + ADD COLUMN IF NOT EXISTS updater_gen INT + NOT NULL DEFAULT 0; diff --git a/schema/crdb/dbinit.sql b/schema/crdb/dbinit.sql index 17ea6d5510e..71c73596e75 100644 --- a/schema/crdb/dbinit.sql +++ b/schema/crdb/dbinit.sql @@ -1007,7 +1007,15 @@ CREATE TABLE IF NOT EXISTS omicron.public.instance ( ncpus INT NOT NULL, memory INT NOT NULL, hostname STRING(63) NOT NULL, - boot_on_fault BOOL NOT NULL DEFAULT false + boot_on_fault BOOL NOT NULL DEFAULT false, + + /* ID of the instance update saga that has locked this instance for + * updating, if one exists. */ + updater_id UUID, + + /* Generation of the instance updater lock */ + updater_gen INT NOT NULL + ); -- Names for instances within a project should be unique