Skip to content

Commit bf6e4bb

Browse files
committed
Unalign a little bit of column order
1 parent 78febbb commit bf6e4bb

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

nexus/db-schema/src/crdb_alignment_test.rs

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

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-
}
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+
);
581582

582583
mismatched_columns.sort();
583584
let actual_drift = format_list(&mismatched_columns);

nexus/db-schema/src/schema.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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>,
450457
time_state_updated -> Timestamptz,
451458
state_generation -> Int8,
452459
active_propolis_id -> Nullable<Uuid>,
453460
target_propolis_id -> Nullable<Uuid>,
454461
migration_id -> Nullable<Uuid>,
455-
ncpus -> Int8,
456-
memory -> Int8,
457-
hostname -> Text,
458-
updater_id -> Nullable<Uuid>,
459-
updater_gen-> Int8,
460462
state -> crate::enums::InstanceStateEnum,
461463
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>,
465464
intended_state -> crate::enums::InstanceIntendedStateEnum,
466-
cpu_platform -> Nullable<crate::enums::InstanceCpuPlatformEnum>,
465+
updater_id -> Nullable<Uuid>,
466+
updater_gen-> Int8,
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,
480478
sled_id -> Uuid,
481479
propolis_ip -> Inet,
482480
propolis_port -> Int4,
483-
state -> crate::enums::VmmStateEnum,
484481
cpu_platform -> crate::enums::VmmCpuPlatformEnum,
482+
time_state_updated -> Timestamptz,
483+
state_generation -> Int8,
484+
state -> crate::enums::VmmStateEnum,
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,
496495
time_created -> Timestamptz,
497496
time_modified -> Timestamptz,
497+
state -> crate::enums::VmmStateEnum,
498+
active_sled_id -> Uuid,
498499
migration_id -> Nullable<Uuid>,
499500
ncpus -> Int8,
500501
memory -> Int8,
501-
state -> crate::enums::VmmStateEnum,
502502
}
503503
}
504504

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance
2+
sled_instance
3+
vmm

0 commit comments

Comments
 (0)