This is the macro:
macro_rules! execute_migrations {
($($version:literal),+) => {{
debug!("Migrating FICD: {}", $version); // this line says the error in the title, x being $version
let expr = include_str!(concat!(
"../../../resources/release/migrations/fidc_",
$version,
"_up.sql"
));
connection.execute_batch(expr).map_err(|e| {
OperationError::new(
CommonExitCodes::FIDCMigrationError as i32,
"An error occured while migrating the file id cache database.",
Some(e),
)
})
}?};
}
I have several files under resources/release/migrations
directory conveniently named fidc_0001_up.sql
where 0001
is the serial version of the migration.
I use rusqlite and its execute_batch
method in order to run my migrations.
I intend to use this macro as below:
execute_migrations!("0001", "0002", "0003"); // and so on
It will write the compilation logic for fidc_*_up.sql
files.
Is there something I don't understand with repetition in macros?
Environment
- Rust 1.57.0 (2021 Edition)