Bläddra i källkod

Correctly sort table list for stable schema signatures.

Kestrel 7 månader sedan
förälder
incheckning
46f7bb3fc9
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10 2
      microrm/src/schema/build.rs

+ 10 - 2
microrm/src/schema/build.rs

@@ -282,7 +282,11 @@ pub(crate) fn collect_from_database<DB: Database>() -> DatabaseSchema {
 
     let mut queries = vec![];
 
-    for (table_name, table) in tables {
+    // create sorted table list
+    let mut sorted_tables : Vec<_> = tables.into_iter().collect();
+    sorted_tables.sort_by(|a, b| a.0.cmp(&b.0));
+
+    for (table_name, table) in sorted_tables {
         let create_sql = table.build_creation_query();
 
         table_name.hash(&mut signature_hasher);
@@ -295,8 +299,12 @@ pub(crate) fn collect_from_database<DB: Database>() -> DatabaseSchema {
         queries.push(iinfo.build_creation_query());
     }
 
+    let signature = signature_hasher.finish();
+
+    log::trace!("Schema signature: {signature:x}");
+
     DatabaseSchema {
-        signature: signature_hasher.finish(),
+        signature,
         queries,
     }
 }