Skip to content

Commit 8154bfe

Browse files
committed
Add a note about automatic rebuilds to the documentation of
`embed_migrations!` (Addresses diesel-rs#3119)
1 parent 3488dbd commit 8154bfe

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • diesel_migrations/migrations_macros/src

diesel_migrations/migrations_macros/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ use proc_macro::TokenStream;
9595
/// Ok(())
9696
/// }
9797
/// ```
98+
///
99+
/// # Automatic rebuilds
100+
///
101+
/// Due to limitations in rusts proc-macro API there is currently no
102+
/// way to signal that a specific proc macro should be rerun if some
103+
/// external file changes/is added. This implies that `embed_migrations!`
104+
/// cannot regenerate the list of embedded migrations if **only** the
105+
/// migrations are changed. This limitation can be solved by adding a
106+
/// custom `build.rs` file to your crate, such that the crate is rebuild
107+
/// if the migration directory changes.
108+
///
109+
/// Add the following `build.rs` file to your project to fix the problem
110+
///
111+
/// ```
112+
/// fn main() {
113+
/// println!("cargo:rerun-if-changed=path/to/your/migration/dir/reletive/to/your/Cargo.toml");
114+
/// }
115+
/// ```
98116
#[proc_macro]
99117
pub fn embed_migrations(input: TokenStream) -> TokenStream {
100118
embed_migrations::expand(input.to_string())

0 commit comments

Comments
 (0)