From 92d31616a91444769d6ae041ce2ef7a255d475ea Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Fri, 20 Dec 2024 00:35:04 -0700 Subject: [PATCH] Revert "always use embedded migrations" This reverts commit ca34b9a9bdd5fd1e4c7021d561950ce45c5012b3. --- crates/db_schema/src/schema_setup.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/db_schema/src/schema_setup.rs b/crates/db_schema/src/schema_setup.rs index 2211f9f2d..c18c7f9cb 100644 --- a/crates/db_schema/src/schema_setup.rs +++ b/crates/db_schema/src/schema_setup.rs @@ -27,12 +27,24 @@ diesel::table! { } } +// In production, include migrations in the binary +#[cfg(not(debug_assertions))] fn migrations() -> diesel_migrations::EmbeddedMigrations { // Using `const` here is required by the borrow checker const MIGRATIONS: diesel_migrations::EmbeddedMigrations = diesel_migrations::embed_migrations!(); MIGRATIONS } +// Avoid recompiling when migrations are changed +#[cfg(debug_assertions)] +#[expect(clippy::expect_used)] +fn migrations() -> diesel_migrations::FileBasedMigrations { + diesel_migrations::FileBasedMigrations::find_migrations_directory_in_path(env!( + "CARGO_MANIFEST_DIR" + )) + .expect("failed to get migration source") +} + /// This SQL code sets up the `r` schema, which contains things that can be safely dropped and /// replaced instead of being changed using migrations. It may not create or modify things outside /// of the `r` schema (indicated by `r.` before the name), unless a comment says otherwise.