database_schema/
macros.rs1#[macro_export]
14macro_rules! generate_without_runtime {
15 ($migrations_path:expr, $structure_path:expr) => {
16 let migrations_path: ::std::path::PathBuf = $migrations_path.into();
17 let destination_path: ::std::path::PathBuf = $structure_path.into();
18 $crate::macros::__generate_within_runtime(migrations_path, destination_path)
19 };
20}
21
22#[macro_export]
24macro_rules! generate_without_runtime_using_defaults {
25 () => {
26 $crate::macros::__generate_within_runtime(
27 ::std::path::PathBuf::from("./migrations"),
28 ::std::path::PathBuf::from("./structure.sql"),
29 );
30 };
31}
32
33#[doc(hidden)]
36pub fn __generate_within_runtime(
37 migrations_path: std::path::PathBuf,
38 destination_path: std::path::PathBuf,
39) {
40 run_runtime(migrations_path, destination_path);
41}
42
43fn run_runtime(migrations_path: std::path::PathBuf, destination_path: std::path::PathBuf) {
44 #[cfg(feature = "runtime-tokio")]
45 {
46 let rt = tokio::runtime::Runtime::new().expect("could not create tokio runtime");
47 let local = tokio::task::LocalSet::new();
48 local
49 .block_on(&rt, async {
50 crate::generate(None, migrations_path, destination_path).await
51 })
52 .expect("could not run tokio runtime");
53 }
54
55 #[cfg(feature = "runtime-async-std")]
56 async_std::task::block_on(async {
57 crate::generate(None, migrations_path, destination_path).await
58 })
59 .expect("could not run async-std runtime");
60}