#[macro_export]
macro_rules! generate_without_runtime {
($migrations_path:expr, $structure_path:expr) => {
let migrations_path: ::std::path::PathBuf = $migrations_path.into();
let destination_path: ::std::path::PathBuf = $structure_path.into();
$crate::macros::__generate_within_runtime(migrations_path, destination_path)
};
}
#[macro_export]
macro_rules! generate_without_runtime_using_defaults {
() => {
$crate::macros::__generate_within_runtime(
::std::path::PathBuf::from("./migrations"),
::std::path::PathBuf::from("./structure.sql"),
);
};
}
#[doc(hidden)]
pub fn __generate_within_runtime(
migrations_path: std::path::PathBuf,
destination_path: std::path::PathBuf,
) {
run_runtime(migrations_path, destination_path);
}
fn run_runtime(migrations_path: std::path::PathBuf, destination_path: std::path::PathBuf) {
#[cfg(feature = "runtime-tokio")]
{
let rt = tokio::runtime::Runtime::new().expect("could not create tokio runtime");
let local = tokio::task::LocalSet::new();
local
.block_on(&rt, async {
crate::generate(None, migrations_path, destination_path).await
})
.expect("could not run tokio runtime");
}
#[cfg(feature = "runtime-async-std")]
async_std::task::block_on(async {
crate::generate(None, migrations_path, destination_path).await
})
.expect("could not run async-std runtime");
}