Skip to content
4 changes: 1 addition & 3 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5018,9 +5018,7 @@ async fn cmd_db_instance_info(
println!(" {VCPUS:>WIDTH$}: {cpus_provisioned}");
println!(" {RAM:>WIDTH$}: {ram}");
println!(" {DISK:>WIDTH$}: {disk}");
if let Some(modified) = time_modified {
println!(" {LAST_UPDATED:>WIDTH$}: {modified}")
}
println!(" {LAST_UPDATED:>WIDTH$}: {time_modified}");
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions nexus/db-model/src/virtual_provisioning_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ pub enum CollectionTypeProvisioned {
/// Describes virtual_provisioning_collection for a collection
#[derive(Clone, Selectable, Queryable, Insertable, Debug)]
#[diesel(table_name = virtual_provisioning_collection)]
#[diesel(treat_none_as_default_value = true)]
pub struct VirtualProvisioningCollection {
pub id: Uuid,
pub time_modified: Option<DateTime<Utc>>,
pub time_modified: DateTime<Utc>,
pub collection_type: String,

pub virtual_disk_bytes_provisioned: ByteCount,
Expand All @@ -34,7 +33,7 @@ impl VirtualProvisioningCollection {
pub fn new(id: Uuid, collection_type: CollectionTypeProvisioned) -> Self {
Self {
id,
time_modified: None,
time_modified: Utc::now(),
collection_type: collection_type.to_string(),
virtual_disk_bytes_provisioned: ByteCount(
external::ByteCount::from(0),
Expand Down
5 changes: 2 additions & 3 deletions nexus/db-model/src/virtual_provisioning_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ impl std::fmt::Display for ResourceTypeProvisioned {
/// Describes virtual_provisioning_resource for a resource.
#[derive(Clone, Selectable, Queryable, Insertable, Debug)]
#[diesel(table_name = virtual_provisioning_resource)]
#[diesel(treat_none_as_default_value = true)]
pub struct VirtualProvisioningResource {
pub id: Uuid,
pub time_modified: Option<DateTime<Utc>>,
pub time_modified: DateTime<Utc>,
pub resource_type: String,

pub virtual_disk_bytes_provisioned: ByteCount,
Expand All @@ -43,7 +42,7 @@ impl VirtualProvisioningResource {
pub fn new(id: Uuid, resource_type: ResourceTypeProvisioned) -> Self {
Self {
id,
time_modified: None,
time_modified: Utc::now(),
resource_type: resource_type.to_string(),
virtual_disk_bytes_provisioned: ByteCount(
external::ByteCount::from(0),
Expand Down
12 changes: 3 additions & 9 deletions nexus/db-queries/src/provisioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ impl Producer {
.iter()
.map(|provision| {
Sample::new_with_timestamp(
provision
.time_modified
.expect("Should always have default value"),
provision.time_modified,
&CollectionTarget { id: provision.id },
&VirtualDiskSpaceProvisioned {
datum: provision.virtual_disk_bytes_provisioned.into(),
Expand All @@ -69,18 +67,14 @@ impl Producer {
.iter()
.map(|provision| {
Sample::new_with_timestamp(
provision
.time_modified
.expect("Should always have default value"),
provision.time_modified,
&CollectionTarget { id: provision.id },
&CpusProvisioned { datum: provision.cpus_provisioned },
)
})
.chain(provisions.iter().map(|provision| {
Sample::new_with_timestamp(
provision
.time_modified
.expect("Should always have default value"),
provision.time_modified,
&CollectionTarget { id: provision.id },
&RamProvisioned { datum: provision.ram_provisioned.into() },
)
Expand Down
17 changes: 5 additions & 12 deletions nexus/db-schema/src/crdb_alignment_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,18 +552,11 @@ async fn diesel_schema_matches_crdb_schema() {
// investigated, not blindly regenerated.

nullable_exceptions.sort();
let actual_nullable = format_list(&nullable_exceptions);
let expected_nullable =
std::fs::read_to_string("tests/output/schema_nullable_exceptions.txt")
.expect("failed to read schema_nullable_exceptions.txt");
similar_asserts::assert_eq!(
expected_nullable,
actual_nullable,
"Nullable exceptions list doesn't match expected.\n\n\
This file tracks columns where CRDB says NOT NULL but Diesel \
says Nullable. If this list changed, investigate whether the \
Diesel schema or CRDB schema should be fixed rather than \
updating the file."
assert!(
nullable_exceptions.is_empty(),
"Found columns where CRDB says NOT NULL but Diesel says Nullable. \
Fix the Diesel schema or CRDB schema rather than adding exceptions: \
{nullable_exceptions:?}"
);

column_order_drift.sort();
Expand Down
12 changes: 2 additions & 10 deletions nexus/db-schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,11 +1166,7 @@ table! {
table! {
virtual_provisioning_collection {
id -> Uuid,
// This type isn't actually "Nullable" - it's just handy to use the
// same type for insertion and querying, and doing so requires this
// field to appear optional so we can let this (default) field appear
// optional.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the DEFAULT NOW() on these two columns in the schema?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 09d4f21

time_modified -> Nullable<Timestamptz>,
time_modified -> Timestamptz,
collection_type -> Text,
virtual_disk_bytes_provisioned -> Int8,
cpus_provisioned -> Int8,
Expand All @@ -1181,11 +1177,7 @@ table! {
table! {
virtual_provisioning_resource {
id -> Uuid,
// This type isn't actually "Nullable" - it's just handy to use the
// same type for insertion and querying, and doing so requires this
// field to appear optional so we can let this (default) field appear
// optional.
time_modified -> Nullable<Timestamptz>,
time_modified -> Timestamptz,
resource_type -> Text,
virtual_disk_bytes_provisioned -> Int8,
cpus_provisioned -> Int8,
Expand Down
2 changes: 0 additions & 2 deletions nexus/db-schema/tests/output/schema_nullable_exceptions.txt

This file was deleted.

Loading