diff --git a/nexus/db-model/src/deployment.rs b/nexus/db-model/src/deployment.rs index 28c9d2448a..c398f6d11c 100644 --- a/nexus/db-model/src/deployment.rs +++ b/nexus/db-model/src/deployment.rs @@ -227,7 +227,6 @@ pub struct BpOmicronZone { pub sled_id: DbTypedUuid, pub id: Uuid, pub underlay_address: ipv6::Ipv6Addr, - pub filesystem_pool: Option>, pub zone_type: ZoneType, pub primary_service_ip: ipv6::Ipv6Addr, pub primary_service_port: SqlU16, @@ -249,6 +248,7 @@ pub struct BpOmicronZone { disposition: DbBpZoneDisposition, pub external_ip_id: Option>, + pub filesystem_pool: Option>, } impl BpOmicronZone { @@ -274,10 +274,6 @@ impl BpOmicronZone { sled_id: zone.sled_id.into(), id: zone.id, underlay_address: zone.underlay_address, - filesystem_pool: blueprint_zone - .filesystem_pool - .as_ref() - .map(|pool| pool.id().into()), zone_type: zone.zone_type, primary_service_ip: zone.primary_service_ip, primary_service_port: zone.primary_service_port, @@ -297,6 +293,10 @@ impl BpOmicronZone { snat_last_port: zone.snat_last_port, disposition: to_db_bp_zone_disposition(blueprint_zone.disposition), external_ip_id: zone.external_ip_id.map(From::from), + filesystem_pool: blueprint_zone + .filesystem_pool + .as_ref() + .map(|pool| pool.id().into()), }) } diff --git a/nexus/db-model/src/inventory.rs b/nexus/db-model/src/inventory.rs index be38250f45..14c4684e1e 100644 --- a/nexus/db-model/src/inventory.rs +++ b/nexus/db-model/src/inventory.rs @@ -1009,7 +1009,6 @@ pub struct InvOmicronZone { pub sled_id: DbTypedUuid, pub id: Uuid, pub underlay_address: ipv6::Ipv6Addr, - pub filesystem_pool: Option>, pub zone_type: ZoneType, pub primary_service_ip: ipv6::Ipv6Addr, pub primary_service_port: SqlU16, @@ -1027,6 +1026,7 @@ pub struct InvOmicronZone { pub snat_ip: Option, pub snat_first_port: Option, pub snat_last_port: Option, + pub filesystem_pool: Option>, } impl InvOmicronZone { @@ -1050,7 +1050,6 @@ impl InvOmicronZone { sled_id: zone.sled_id.into(), id: zone.id, underlay_address: zone.underlay_address, - filesystem_pool: zone.filesystem_pool.map(|id| id.into()), zone_type: zone.zone_type, primary_service_ip: zone.primary_service_ip, primary_service_port: zone.primary_service_port, @@ -1068,6 +1067,7 @@ impl InvOmicronZone { snat_ip: zone.snat_ip, snat_first_port: zone.snat_first_port, snat_last_port: zone.snat_last_port, + filesystem_pool: zone.filesystem_pool.map(|id| id.into()), }) } diff --git a/nexus/db-model/src/schema.rs b/nexus/db-model/src/schema.rs index 5e87f9e1a2..056e143fbe 100644 --- a/nexus/db-model/src/schema.rs +++ b/nexus/db-model/src/schema.rs @@ -1454,7 +1454,6 @@ table! { id -> Uuid, underlay_address -> Inet, - filesystem_pool -> Nullable, zone_type -> crate::ZoneTypeEnum, primary_service_ip -> Inet, @@ -1473,6 +1472,7 @@ table! { snat_ip -> Nullable, snat_first_port -> Nullable, snat_last_port -> Nullable, + filesystem_pool -> Nullable, } } @@ -1569,7 +1569,6 @@ table! { id -> Uuid, underlay_address -> Inet, - filesystem_pool -> Nullable, zone_type -> crate::ZoneTypeEnum, primary_service_ip -> Inet, @@ -1590,6 +1589,7 @@ table! { snat_last_port -> Nullable, disposition -> crate::DbBpZoneDispositionEnum, external_ip_id -> Nullable, + filesystem_pool -> Nullable, } } diff --git a/nexus/db-model/src/schema_versions.rs b/nexus/db-model/src/schema_versions.rs index 04fafe4f93..09978f21ad 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(77, 0, 0); +pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(78, 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(78, "add-nullable-filesystem-pool"), KnownVersion::new(77, "remove-view-for-v2p-mappings"), KnownVersion::new(76, "lookup-region-snapshot-by-snapshot-id"), KnownVersion::new(75, "add-cockroach-zone-id-to-node-id"), diff --git a/schema/crdb/add-nullable-filesystem-pool/up1.sql b/schema/crdb/add-nullable-filesystem-pool/up1.sql new file mode 100644 index 0000000000..53c58db51c --- /dev/null +++ b/schema/crdb/add-nullable-filesystem-pool/up1.sql @@ -0,0 +1 @@ +ALTER TABLE omicron.public.inv_omicron_zone ADD COLUMN IF NOT EXISTS filesystem_pool UUID; diff --git a/schema/crdb/add-nullable-filesystem-pool/up2.sql b/schema/crdb/add-nullable-filesystem-pool/up2.sql new file mode 100644 index 0000000000..f1a3b71e30 --- /dev/null +++ b/schema/crdb/add-nullable-filesystem-pool/up2.sql @@ -0,0 +1 @@ +ALTER TABLE omicron.public.bp_omicron_zone ADD COLUMN IF NOT EXISTS filesystem_pool UUID; diff --git a/schema/crdb/dbinit.sql b/schema/crdb/dbinit.sql index c43a5b98e8..8bd7284f9c 100644 --- a/schema/crdb/dbinit.sql +++ b/schema/crdb/dbinit.sql @@ -3178,9 +3178,6 @@ CREATE TABLE IF NOT EXISTS omicron.public.inv_omicron_zone ( -- unique id for this zone id UUID NOT NULL, underlay_address INET NOT NULL, - -- TODO: This is nullable for backwards compatibility. - -- Eventually, that nullability should be removed. - filesystem_pool UUID, zone_type omicron.public.zone_type NOT NULL, -- SocketAddr of the "primary" service for this zone @@ -3233,6 +3230,10 @@ CREATE TABLE IF NOT EXISTS omicron.public.inv_omicron_zone ( snat_last_port INT4 CHECK (snat_last_port IS NULL OR snat_last_port BETWEEN 0 AND 65535), + -- TODO: This is nullable for backwards compatibility. + -- Eventually, that nullability should be removed. + filesystem_pool UUID, + PRIMARY KEY (inv_collection_id, id) ); @@ -3415,9 +3416,6 @@ CREATE TABLE IF NOT EXISTS omicron.public.bp_omicron_zone ( -- unique id for this zone id UUID NOT NULL, underlay_address INET NOT NULL, - -- TODO: This is nullable for backwards compatibility. - -- Eventually, that nullability should be removed. - filesystem_pool UUID, zone_type omicron.public.zone_type NOT NULL, -- SocketAddr of the "primary" service for this zone @@ -3482,6 +3480,10 @@ CREATE TABLE IF NOT EXISTS omicron.public.bp_omicron_zone ( -- created yet. external_ip_id UUID, + -- TODO: This is nullable for backwards compatibility. + -- Eventually, that nullability should be removed. + filesystem_pool UUID, + PRIMARY KEY (blueprint_id, id) ); @@ -4104,7 +4106,7 @@ INSERT INTO omicron.public.db_metadata ( version, target_version ) VALUES - (TRUE, NOW(), NOW(), '77.0.0', NULL) + (TRUE, NOW(), NOW(), '78.0.0', NULL) ON CONFLICT DO NOTHING; COMMIT;