Skip to content

Commit 78febbb

Browse files
committed
Align column order
1 parent 685088e commit 78febbb

File tree

4 files changed

+59
-77
lines changed

4 files changed

+59
-77
lines changed

nexus/db-model/src/oximeter_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ pub struct OximeterInfo {
2020
pub time_created: DateTime<Utc>,
2121
/// When this resource was last modified.
2222
pub time_modified: DateTime<Utc>,
23+
/// The address on which this `oximeter` instance listens for requests.
24+
pub ip: ipnetwork::IpNetwork,
25+
/// The port on which this `oximeter` instance listens for requests.
26+
pub port: SqlU16,
2327
/// When this resource was expunged.
2428
//
2529
// We typically refer to _zones_ as expunged; this isn't quite the same
@@ -31,10 +35,6 @@ pub struct OximeterInfo {
3135
// producers (and will result in any producers it had been assigned being
3236
// reassigned to some other collector).
3337
pub time_expunged: Option<DateTime<Utc>>,
34-
/// The address on which this `oximeter` instance listens for requests.
35-
pub ip: ipnetwork::IpNetwork,
36-
/// The port on which this `oximeter` instance listens for requests.
37-
pub port: SqlU16,
3838
}
3939

4040
impl OximeterInfo {

nexus/db-schema/src/crdb_alignment_test.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -566,19 +566,18 @@ async fn diesel_schema_matches_crdb_schema() {
566566
updating the file."
567567
);
568568

569-
column_order_drift.sort();
570-
let actual_order = format_list(&column_order_drift);
571-
let expected_order =
572-
std::fs::read_to_string("tests/output/schema_column_order_drift.txt")
573-
.expect("failed to read schema_column_order_drift.txt");
574-
similar_asserts::assert_eq!(
575-
expected_order,
576-
actual_order,
577-
"Column order drift list doesn't match expected.\n\n\
578-
This file tracks tables where the column order in schema.rs \
579-
differs from CRDB. If this list changed, investigate whether \
580-
the column order should be fixed rather than updating the file."
581-
);
569+
if !column_order_drift.is_empty() {
570+
column_order_drift.sort();
571+
panic!(
572+
"Column order in schema.rs differs from CRDB for {} table(s):\n\n\
573+
{}\n\n\
574+
The column order in the Diesel table! macro must match the \
575+
column order in CRDB (dbinit.sql). Reorder the columns in \
576+
schema.rs to match.",
577+
column_order_drift.len(),
578+
column_order_drift.join("\n"),
579+
);
580+
}
582581

583582
mismatched_columns.sort();
584583
let actual_drift = format_list(&mismatched_columns);

nexus/db-schema/src/schema.rs

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ table! {
4444
disk_state -> Text,
4545
attach_instance_id -> Nullable<Uuid>,
4646
state_generation -> Int8,
47-
time_state_updated -> Timestamptz,
4847
slot -> Nullable<Int2>,
48+
time_state_updated -> Timestamptz,
4949
size_bytes -> Int8,
5050
block_size -> crate::enums::BlockSizeEnum,
5151
disk_type -> crate::enums::DiskTypeEnum,
@@ -203,10 +203,10 @@ table! {
203203
chassis_id -> Nullable<Text>,
204204
system_name -> Nullable<Text>,
205205
system_description -> Nullable<Text>,
206-
management_ip -> Nullable<Inet>,
207206
time_created -> Timestamptz,
208207
time_modified -> Timestamptz,
209208
time_deleted -> Nullable<Timestamptz>,
209+
management_ip -> Nullable<Inet>,
210210
}
211211
}
212212

@@ -310,8 +310,8 @@ table! {
310310
time_modified -> Timestamptz,
311311
time_deleted -> Nullable<Timestamptz>,
312312
asn -> Int8,
313-
bgp_announce_set_id -> Uuid,
314313
vrf -> Nullable<Text>,
314+
bgp_announce_set_id -> Uuid,
315315
shaper -> Nullable<Text>,
316316
checker -> Nullable<Text>,
317317
max_paths -> Int2,
@@ -323,11 +323,10 @@ table! {
323323
switch_location -> Text,
324324
port_name -> Text,
325325
addr -> Nullable<Inet>,
326-
asn -> Int8,
327-
connect_retry -> Int8,
328-
delay_open -> Int8,
329326
hold_time -> Int8,
330327
idle_hold_time -> Int8,
328+
delay_open -> Int8,
329+
connect_retry -> Int8,
331330
keepalive -> Int8,
332331
remote_asn -> Nullable<Int8>,
333332
min_ttl -> Nullable<Int8>,
@@ -337,6 +336,7 @@ table! {
337336
enforce_first_as -> Bool,
338337
vlan_id -> Nullable<Int4>,
339338
router_lifetime -> Int4,
339+
asn -> Int8,
340340
}
341341
}
342342

@@ -447,23 +447,23 @@ table! {
447447
time_deleted -> Nullable<Timestamptz>,
448448
project_id -> Uuid,
449449
user_data -> Binary,
450-
ncpus -> Int8,
451-
memory -> Int8,
452-
hostname -> Text,
453-
auto_restart_policy -> Nullable<crate::enums::InstanceAutoRestartPolicyEnum>,
454-
auto_restart_cooldown -> Nullable<Interval>,
455-
boot_disk_id -> Nullable<Uuid>,
456-
cpu_platform -> Nullable<crate::enums::InstanceCpuPlatformEnum>,
457450
time_state_updated -> Timestamptz,
458451
state_generation -> Int8,
459452
active_propolis_id -> Nullable<Uuid>,
460453
target_propolis_id -> Nullable<Uuid>,
461454
migration_id -> Nullable<Uuid>,
455+
ncpus -> Int8,
456+
memory -> Int8,
457+
hostname -> Text,
458+
updater_id -> Nullable<Uuid>,
459+
updater_gen-> Int8,
462460
state -> crate::enums::InstanceStateEnum,
463461
time_last_auto_restarted -> Nullable<Timestamptz>,
462+
auto_restart_policy -> Nullable<crate::enums::InstanceAutoRestartPolicyEnum>,
463+
auto_restart_cooldown -> Nullable<Interval>,
464+
boot_disk_id -> Nullable<Uuid>,
464465
intended_state -> crate::enums::InstanceIntendedStateEnum,
465-
updater_id -> Nullable<Uuid>,
466-
updater_gen-> Int8,
466+
cpu_platform -> Nullable<crate::enums::InstanceCpuPlatformEnum>,
467467
}
468468
}
469469

@@ -475,13 +475,13 @@ table! {
475475
time_created -> Timestamptz,
476476
time_deleted -> Nullable<Timestamptz>,
477477
instance_id -> Uuid,
478+
time_state_updated -> Timestamptz,
479+
state_generation -> Int8,
478480
sled_id -> Uuid,
479481
propolis_ip -> Inet,
480482
propolis_port -> Int4,
481-
cpu_platform -> crate::enums::VmmCpuPlatformEnum,
482-
time_state_updated -> Timestamptz,
483-
state_generation -> Int8,
484483
state -> crate::enums::VmmStateEnum,
484+
cpu_platform -> crate::enums::VmmCpuPlatformEnum,
485485
}
486486
}
487487
joinable!(vmm -> sled (sled_id));
@@ -492,13 +492,13 @@ table! {
492492
name -> Text,
493493
silo_name -> Text,
494494
project_name -> Text,
495+
active_sled_id -> Uuid,
495496
time_created -> Timestamptz,
496497
time_modified -> Timestamptz,
497-
state -> crate::enums::VmmStateEnum,
498-
active_sled_id -> Uuid,
499498
migration_id -> Nullable<Uuid>,
500499
ncpus -> Int8,
501500
memory -> Int8,
501+
state -> crate::enums::VmmStateEnum,
502502
}
503503
}
504504

@@ -572,13 +572,13 @@ table! {
572572
silo_utilization(silo_id) {
573573
silo_id -> Uuid,
574574
silo_name -> Text,
575-
silo_discoverable -> Bool,
576575
cpus_provisioned -> Int8,
577576
memory_provisioned -> Int8,
578577
storage_provisioned -> Int8,
579578
cpus_allocated -> Int8,
580579
memory_allocated -> Int8,
581580
storage_allocated -> Int8,
581+
silo_discoverable -> Bool,
582582
}
583583
}
584584

@@ -608,11 +608,11 @@ table! {
608608
// original name of `ip` because renaming columns is not idempotent in
609609
// CRDB as of today.
610610
ip -> Nullable<Inet>,
611-
ipv6 -> Nullable<Inet>,
612611
slot -> Int2,
613612
is_primary -> Bool,
614613
// NOTE: These are the IPv4 transit IPs specifically.
615614
transit_ips -> Array<Inet>,
615+
ipv6 -> Nullable<Inet>,
616616
transit_ips_v6 -> Array<Inet>,
617617
}
618618
}
@@ -666,8 +666,8 @@ table! {
666666
time_created -> Timestamptz,
667667
time_modified -> Timestamptz,
668668
time_deleted -> Nullable<Timestamptz>,
669-
ip_version -> crate::enums::IpVersionEnum,
670669
rcgen -> Int8,
670+
ip_version -> crate::enums::IpVersionEnum,
671671
reservation_type -> crate::enums::IpPoolReservationTypeEnum,
672672
pool_type -> crate::enums::IpPoolTypeEnum,
673673
}
@@ -980,9 +980,9 @@ table! {
980980
id -> Uuid,
981981
time_created -> Timestamptz,
982982
time_modified -> Timestamptz,
983-
time_expunged -> Nullable<Timestamptz>,
984983
ip -> Inet,
985984
port -> Int4,
985+
time_expunged -> Nullable<Timestamptz>,
986986
}
987987
}
988988

@@ -1104,11 +1104,11 @@ table! {
11041104
}
11051105

11061106
table! {
1107-
sled_underlay_subnet_allocation (rack_id, sled_id) {
1107+
sled_underlay_subnet_allocation (hw_baseboard_id, sled_id) {
1108+
hw_baseboard_id -> Uuid,
11081109
rack_id -> Uuid,
11091110
sled_id -> Uuid,
11101111
subnet_octet -> Int2,
1111-
hw_baseboard_id -> Uuid,
11121112
}
11131113
}
11141114
allow_tables_to_appear_in_same_query!(rack, sled_underlay_subnet_allocation);
@@ -1141,9 +1141,9 @@ table! {
11411141
model -> Text,
11421142

11431143
variant -> crate::enums::PhysicalDiskKindEnum,
1144+
sled_id -> Uuid,
11441145
disk_policy -> crate::enums::PhysicalDiskPolicyEnum,
11451146
disk_state -> crate::enums::PhysicalDiskStateEnum,
1146-
sled_id -> Uuid,
11471147
}
11481148
}
11491149

@@ -1323,9 +1323,9 @@ table! {
13231323
time_deleted -> Nullable<Timestamptz>,
13241324
project_id -> Uuid,
13251325
system_router_id -> Uuid,
1326+
dns_name -> Text,
13261327
vni -> Int4,
13271328
ipv6_prefix -> Inet,
1328-
dns_name -> Text,
13291329
firewall_gen -> Int8,
13301330
subnet_gen -> Int8,
13311331
}
@@ -1370,8 +1370,8 @@ table! {
13701370
time_created -> Timestamptz,
13711371
time_modified -> Timestamptz,
13721372
time_deleted -> Nullable<Timestamptz>,
1373-
kind -> crate::enums::RouterRouteKindEnum,
13741373
vpc_router_id -> Uuid,
1374+
kind -> crate::enums::RouterRouteKindEnum,
13751375
target -> Text,
13761376
destination -> Text,
13771377
vpc_subnet_id -> Nullable<Uuid>,
@@ -1504,17 +1504,17 @@ table! {
15041504

15051505
table! {
15061506
role_assignment (
1507-
identity_type,
1508-
identity_id,
1509-
resource_type,
15101507
resource_id,
1511-
role_name
1508+
resource_type,
1509+
role_name,
1510+
identity_id,
1511+
identity_type
15121512
) {
1513-
identity_type -> crate::enums::IdentityTypeEnum,
1514-
identity_id -> Uuid,
15151513
resource_type -> Text,
15161514
role_name -> Text,
15171515
resource_id -> Uuid,
1516+
identity_id -> Uuid,
1517+
identity_type -> crate::enums::IdentityTypeEnum,
15181518
}
15191519
}
15201520

@@ -1746,7 +1746,6 @@ table! {
17461746
sled_role -> crate::enums::SledRoleEnum,
17471747
usable_hardware_threads -> Int8,
17481748
usable_physical_ram -> Int8,
1749-
cpu_family -> crate::enums::SledCpuFamilyEnum,
17501749
reservoir_size -> Int8,
17511750

17521751
ledgered_sled_config -> Nullable<Uuid>,
@@ -1760,14 +1759,16 @@ table! {
17601759
zone_manifest_mupdate_id -> Nullable<Uuid>,
17611760
zone_manifest_boot_disk_error -> Nullable<Text>,
17621761

1762+
mupdate_override_boot_disk_path -> Text,
1763+
mupdate_override_id -> Nullable<Uuid>,
1764+
mupdate_override_boot_disk_error -> Nullable<Text>,
1765+
1766+
cpu_family -> crate::enums::SledCpuFamilyEnum,
1767+
17631768
measurement_manifest_boot_disk_path -> Text,
17641769
measurement_manifest_source -> Nullable<crate::enums::InvZoneManifestSourceEnum>,
17651770
measurement_manifest_mupdate_id -> Nullable<Uuid>,
17661771
measurement_manifest_boot_disk_error -> Nullable<Text>,
1767-
1768-
mupdate_override_boot_disk_path -> Text,
1769-
mupdate_override_id -> Nullable<Uuid>,
1770-
mupdate_override_boot_disk_error -> Nullable<Text>,
17711772
}
17721773
}
17731774

@@ -2248,11 +2249,11 @@ table! {
22482249
snat_ip -> Nullable<Inet>,
22492250
snat_first_port -> Nullable<Int4>,
22502251
snat_last_port -> Nullable<Int4>,
2252+
external_ip_id -> Nullable<Uuid>,
2253+
filesystem_pool -> Uuid,
22512254
disposition -> crate::enums::BpZoneDispositionEnum,
22522255
disposition_expunged_as_of_generation -> Nullable<Int8>,
22532256
disposition_expunged_ready_for_cleanup -> Bool,
2254-
external_ip_id -> Nullable<Uuid>,
2255-
filesystem_pool -> Uuid,
22562257
image_source -> crate::enums::BpZoneImageSourceEnum,
22572258
image_artifact_sha256 -> Nullable<Text>,
22582259
nexus_generation -> Nullable<Int8>,

nexus/db-schema/tests/output/schema_column_order_drift.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)