Skip to content
6 changes: 6 additions & 0 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6767,6 +6767,8 @@ async fn cmd_db_inventory_cabooses(
git_commit: String,
name: String,
version: String,
#[tabled(display_with = "option_impl_display")]
sign: Option<String>,
}

use nexus_db_schema::schema::sw_caboose::dsl;
Expand All @@ -6785,6 +6787,7 @@ async fn cmd_db_inventory_cabooses(
name: caboose.name,
version: caboose.version,
git_commit: caboose.git_commit,
sign: caboose.sign,
});
let table = tabled::Table::new(rows)
.with(tabled::settings::Style::empty())
Expand Down Expand Up @@ -7133,6 +7136,8 @@ async fn inv_collection_print_devices(
name: &'a str,
version: &'a str,
git_commit: &'a str,
#[tabled(display_with = "option_impl_display")]
sign: &'a Option<String>,
}

println!(" cabooses:");
Expand All @@ -7146,6 +7151,7 @@ async fn inv_collection_print_devices(
name: &found_caboose.caboose.name,
version: &found_caboose.caboose.version,
git_commit: &found_caboose.caboose.git_commit,
sign: &found_caboose.caboose.sign,
})
.collect();
let table = tabled::Table::new(caboose_rows)
Expand Down
3 changes: 3 additions & 0 deletions nexus/db-model/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ pub struct SwCaboose {
pub git_commit: String,
pub name: String,
pub version: String,
pub sign: Option<String>,
}

impl From<Caboose> for SwCaboose {
Expand All @@ -468,6 +469,7 @@ impl From<Caboose> for SwCaboose {
git_commit: c.git_commit,
name: c.name,
version: c.version,
sign: c.sign,
}
}
}
Expand All @@ -479,6 +481,7 @@ impl From<SwCaboose> for Caboose {
git_commit: row.git_commit,
name: row.name,
version: row.version,
sign: row.sign,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// 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: Version = Version::new(140, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(141, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::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(141, "caboose-sign-value"),
KnownVersion::new(140, "instance-intended-state"),
KnownVersion::new(139, "webhooks"),
KnownVersion::new(138, "saga-abandoned-state"),
Expand Down
9 changes: 7 additions & 2 deletions nexus/db-queries/src/db/datastore/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use diesel::IntoSql;
use diesel::JoinOnDsl;
use diesel::NullableExpressionMethods;
use diesel::OptionalExtension;
use diesel::PgExpressionMethods;
use diesel::QueryDsl;
use diesel::Table;
use diesel::expression::SelectableHelper;
Expand Down Expand Up @@ -554,7 +555,7 @@ impl DataStore {
// - `hw_baseboard` with an "id" primary key and lookup columns
// "part_number" and "serial_number"
// - `sw_caboose` with an "id" primary key and lookup columns
// "board", "git_commit", "name", and "version"
// "board", "git_commit", "name", "version", and "sign"
// - `inv_caboose` with foreign keys "hw_baseboard_id",
// "sw_caboose_id", and various other columns
//
Expand Down Expand Up @@ -596,7 +597,8 @@ impl DataStore {
// AND sw_caboose.board = ...
// AND sw_caboose.git_commit = ...
// AND sw_caboose.name = ...
// AND sw_caboose.version = ...;
// AND sw_caboose.version = ...
// AND sw_caboose.sign IS NOT DISTINCT FROM ...;
//
// Again, the whole point is to avoid back-and-forth between the
// client and the database. Those back-and-forth interactions can
Expand Down Expand Up @@ -642,6 +644,9 @@ impl DataStore {
)
.and(dsl_sw_caboose::version.eq(
found_caboose.caboose.version.clone(),
))
.and(dsl_sw_caboose::sign.is_not_distinct_from(
found_caboose.caboose.sign.clone(),
)),
),
)
Expand Down
1 change: 1 addition & 0 deletions nexus/db-schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ table! {
git_commit -> Text,
name -> Text,
version -> Text,
sign -> Nullable<Text>,
}
}

Expand Down
7 changes: 4 additions & 3 deletions nexus/inventory/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ mod test {
git_commit: String::from("git_commit_1"),
name: String::from("name_1"),
version: String::from("version_1"),
sign: Some(String::from("sign_1")),
};
for bb in &common_caboose_baseboards {
let _ = collection.sps.get(*bb).unwrap();
Expand Down Expand Up @@ -1105,7 +1106,7 @@ mod test {
git_commit: String::from("git_commit1"),
name: String::from("name1"),
version: String::from("version1"),
sign: None,
sign: Some(String::from("sign1")),
epoch: None,
};
assert!(
Expand All @@ -1125,7 +1126,7 @@ mod test {
"reporting caboose for unknown baseboard: \
BaseboardId { part_number: \"p1\", serial_number: \"bogus\" } \
(Caboose { board: \"board1\", git_commit: \"git_commit1\", \
name: \"name1\", version: \"version1\" })"
name: \"name1\", version: \"version1\", sign: Some(\"sign1\") })"
);
assert!(
!builder
Expand Down Expand Up @@ -1177,7 +1178,7 @@ mod test {
git_commit: String::from("git_commit2"),
name: String::from("name2"),
version: String::from("version2"),
sign: None,
sign: Some(String::from("sign2")),
epoch: None,
},
)
Expand Down
4 changes: 2 additions & 2 deletions nexus/inventory/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ mod test {
for c in &collection.cabooses {
write!(
&mut s,
" board {:?} name {:?} version {:?} git_commit {:?}\n",
c.board, c.name, c.version, c.git_commit,
" board {:?} name {:?} version {:?} git_commit {:?} sign {:?}\n",
c.board, c.name, c.version, c.git_commit, c.sign,
)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion nexus/inventory/src/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ pub fn caboose(unique: &str) -> SpComponentCaboose {
git_commit: format!("git_commit_{}", unique),
name: format!("name_{}", unique),
version: format!("version_{}", unique),
sign: None,
sign: Some(format!("sign_{}", unique)),
epoch: None,
}
}
Expand Down
24 changes: 12 additions & 12 deletions nexus/inventory/tests/output/collector_basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ baseboards:
part "sim-gimlet" serial "sim-9cb9b78f-5614-440c-b66d-e8e81fab69b0"

cabooses:
board "SimGimletSp" name "SimGimlet" version "0.0.1" git_commit "fefefefe"
board "SimGimletSp" name "SimGimlet" version "0.0.2" git_commit "ffffffff"
board "SimRot" name "SimGimletRot" version "0.0.3" git_commit "edededed"
board "SimRot" name "SimSidecarRot" version "0.0.3" git_commit "edededed"
board "SimRot" name "SimGimletRot" version "0.0.4" git_commit "eeeeeeee"
board "SimRot" name "SimSidecarRot" version "0.0.4" git_commit "eeeeeeee"
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "dadadadad"
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "dadadadad"
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "ddddddddd"
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "ddddddddd"
board "SimSidecarSp" name "SimSidecar" version "0.0.1" git_commit "fefefefe"
board "SimSidecarSp" name "SimSidecar" version "0.0.2" git_commit "ffffffff"
board "SimGimletSp" name "SimGimlet" version "0.0.1" git_commit "fefefefe" sign None
board "SimGimletSp" name "SimGimlet" version "0.0.2" git_commit "ffffffff" sign None
board "SimRot" name "SimGimletRot" version "0.0.3" git_commit "edededed" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimSidecarRot" version "0.0.3" git_commit "edededed" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimGimletRot" version "0.0.4" git_commit "eeeeeeee" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimSidecarRot" version "0.0.4" git_commit "eeeeeeee" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "dadadadad" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "dadadadad" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "ddddddddd" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "ddddddddd" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimSidecarSp" name "SimSidecar" version "0.0.1" git_commit "fefefefe" sign None
board "SimSidecarSp" name "SimSidecar" version "0.0.2" git_commit "ffffffff" sign None

rot pages:
data_base64 "Z2ltbGV0LWNmcGEtYWN0aXZlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
Expand Down
24 changes: 12 additions & 12 deletions nexus/inventory/tests/output/collector_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ baseboards:
part "i86pc" serial "SimGimlet01"

cabooses:
board "SimGimletSp" name "SimGimlet" version "0.0.1" git_commit "fefefefe"
board "SimGimletSp" name "SimGimlet" version "0.0.2" git_commit "ffffffff"
board "SimRot" name "SimGimletRot" version "0.0.3" git_commit "edededed"
board "SimRot" name "SimSidecarRot" version "0.0.3" git_commit "edededed"
board "SimRot" name "SimGimletRot" version "0.0.4" git_commit "eeeeeeee"
board "SimRot" name "SimSidecarRot" version "0.0.4" git_commit "eeeeeeee"
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "dadadadad"
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "dadadadad"
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "ddddddddd"
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "ddddddddd"
board "SimSidecarSp" name "SimSidecar" version "0.0.1" git_commit "fefefefe"
board "SimSidecarSp" name "SimSidecar" version "0.0.2" git_commit "ffffffff"
board "SimGimletSp" name "SimGimlet" version "0.0.1" git_commit "fefefefe" sign None
board "SimGimletSp" name "SimGimlet" version "0.0.2" git_commit "ffffffff" sign None
board "SimRot" name "SimGimletRot" version "0.0.3" git_commit "edededed" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimSidecarRot" version "0.0.3" git_commit "edededed" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimGimletRot" version "0.0.4" git_commit "eeeeeeee" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimSidecarRot" version "0.0.4" git_commit "eeeeeeee" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "dadadadad" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "dadadadad" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "ddddddddd" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "ddddddddd" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimSidecarSp" name "SimSidecar" version "0.0.1" git_commit "fefefefe" sign None
board "SimSidecarSp" name "SimSidecar" version "0.0.2" git_commit "ffffffff" sign None

rot pages:
data_base64 "Z2ltbGV0LWNmcGEtYWN0aXZlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
Expand Down
24 changes: 12 additions & 12 deletions nexus/inventory/tests/output/collector_sled_agent_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ baseboards:
part "sim-gimlet" serial "sim-9cb9b78f-5614-440c-b66d-e8e81fab69b0"

cabooses:
board "SimGimletSp" name "SimGimlet" version "0.0.1" git_commit "fefefefe"
board "SimGimletSp" name "SimGimlet" version "0.0.2" git_commit "ffffffff"
board "SimRot" name "SimGimletRot" version "0.0.3" git_commit "edededed"
board "SimRot" name "SimSidecarRot" version "0.0.3" git_commit "edededed"
board "SimRot" name "SimGimletRot" version "0.0.4" git_commit "eeeeeeee"
board "SimRot" name "SimSidecarRot" version "0.0.4" git_commit "eeeeeeee"
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "dadadadad"
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "dadadadad"
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "ddddddddd"
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "ddddddddd"
board "SimSidecarSp" name "SimSidecar" version "0.0.1" git_commit "fefefefe"
board "SimSidecarSp" name "SimSidecar" version "0.0.2" git_commit "ffffffff"
board "SimGimletSp" name "SimGimlet" version "0.0.1" git_commit "fefefefe" sign None
board "SimGimletSp" name "SimGimlet" version "0.0.2" git_commit "ffffffff" sign None
board "SimRot" name "SimGimletRot" version "0.0.3" git_commit "edededed" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimSidecarRot" version "0.0.3" git_commit "edededed" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimGimletRot" version "0.0.4" git_commit "eeeeeeee" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRot" name "SimSidecarRot" version "0.0.4" git_commit "eeeeeeee" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "dadadadad" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "dadadadad" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimGimletRot" version "0.0.200" git_commit "ddddddddd" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimRotStage0" name "SimSidecarRot" version "0.0.200" git_commit "ddddddddd" sign Some("11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf")
board "SimSidecarSp" name "SimSidecar" version "0.0.1" git_commit "fefefefe" sign None
board "SimSidecarSp" name "SimSidecar" version "0.0.2" git_commit "ffffffff" sign None

rot pages:
data_base64 "Z2ltbGV0LWNmcGEtYWN0aXZlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
Expand Down
4 changes: 4 additions & 0 deletions nexus/types/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ pub struct Caboose {
pub git_commit: String,
pub name: String,
pub version: String,
// The sign will generally be present for production RoT and RoT bootloader images.
// It's currently absent from SP images and could be absent from RoT images as well.
pub sign: Option<String>,
}

impl From<gateway_client::types::SpComponentCaboose> for Caboose {
Expand All @@ -269,6 +272,7 @@ impl From<gateway_client::types::SpComponentCaboose> for Caboose {
git_commit: c.git_commit,
name: c.name,
version: c.version,
sign: c.sign,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions schema/crdb/caboose-sign-value/up01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE omicron.public.sw_caboose
ADD COLUMN IF NOT EXISTS sign TEXT; -- nullable
1 change: 1 addition & 0 deletions schema/crdb/caboose-sign-value/up02.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX IF EXISTS omicron.public.sw_caboose@caboose_properties;
2 changes: 2 additions & 0 deletions schema/crdb/caboose-sign-value/up03.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE UNIQUE INDEX IF NOT EXISTS caboose_properties
on omicron.public.sw_caboose (board, git_commit, name, version, sign);
3 changes: 3 additions & 0 deletions schema/crdb/caboose-sign-value/up04.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE UNIQUE INDEX IF NOT EXISTS caboose_properties_no_sign
on omicron.public.sw_caboose (board, git_commit, name, version)
WHERE sign IS NULL;
18 changes: 15 additions & 3 deletions schema/crdb/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3375,10 +3375,22 @@ CREATE TABLE IF NOT EXISTS omicron.public.sw_caboose (
board TEXT NOT NULL,
git_commit TEXT NOT NULL,
name TEXT NOT NULL,
version TEXT NOT NULL
version TEXT NOT NULL,
sign TEXT -- nullable
);

/*
* We use a complete and a partial index to ensure uniqueness.
* This is necessary because the sign column is NULLable, but in SQL, NULL values
* are considered distinct. That means that a single complete index on all of these
* columns would allow duplicate rows where sign is NULL, which we don't want.
*/
CREATE UNIQUE INDEX IF NOT EXISTS caboose_properties
on omicron.public.sw_caboose (board, git_commit, name, version);
on omicron.public.sw_caboose (board, git_commit, name, version, sign);

CREATE UNIQUE INDEX IF NOT EXISTS caboose_properties_no_sign
on omicron.public.sw_caboose (board, git_commit, name, version)
WHERE sign IS NULL;

/* root of trust pages: this table assigns unique ids to distinct RoT CMPA
and CFPA page contents, each of which is a 512-byte blob */
Expand Down Expand Up @@ -5504,7 +5516,7 @@ INSERT INTO omicron.public.db_metadata (
version,
target_version
) VALUES
(TRUE, NOW(), NOW(), '140.0.0', NULL)
(TRUE, NOW(), NOW(), '141.0.0', NULL)
ON CONFLICT DO NOTHING;

COMMIT;
Loading