From 2ef89bddb9c420ef42b3eebe1e3fd148d78940f2 Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Tue, 19 Nov 2024 23:36:35 -0700 Subject: [PATCH] don't assume that migrations are already sorted --- crates/db_schema/src/schema_setup.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/db_schema/src/schema_setup.rs b/crates/db_schema/src/schema_setup.rs index 610af8f05..ef70da296 100644 --- a/crates/db_schema/src/schema_setup.rs +++ b/crates/db_schema/src/schema_setup.rs @@ -275,7 +275,13 @@ fn run_selected_migrations( .enable_diff_check .then(|| diesel::migration::MigrationSource::::migrations(&migrations())) .transpose()? - .and_then(|migrations| Some(migrations.last()?.name().to_string())), + // Get the migration with the highest version + .and_then(|migrations| { + migrations + .into_iter() + .map(|migration| migration.name().to_string()) + .max() + }), }; if options.revert {