mysql_connector/migrator/
mod.rs

1mod migration;
2mod migrator_inner;
3mod model;
4
5pub use {
6    migration::{Migration, MigrationList, Version},
7    migrator_inner::Migrator,
8};
9
10#[macro_export]
11macro_rules! simple_migration {
12    ($name:ident, $up:literal, $down:literal $(,)?) => {
13        struct $name;
14
15        impl mysql_connector::Migration for $name {
16            fn name(&self) -> &'static str {
17                stringify!($name)
18            }
19
20            fn up<'a>(
21                &'a self,
22                pool: &'a dyn mysql_connector::pool::AsyncPoolTrait<mysql_connector::Connection>,
23            ) -> std::pin::Pin<
24                Box<
25                    dyn std::future::Future<Output = Result<(), mysql_connector::error::Error>>
26                        + 'a,
27                >,
28            > {
29                Box::pin(async { pool.get().await?.execute_query($up).await.map(|_| {}) })
30            }
31
32            fn down<'a>(
33                &'a self,
34                pool: &'a dyn mysql_connector::pool::AsyncPoolTrait<mysql_connector::Connection>,
35            ) -> std::pin::Pin<
36                Box<
37                    dyn std::future::Future<Output = Result<(), mysql_connector::error::Error>>
38                        + 'a,
39                >,
40            > {
41                Box::pin(async { pool.get().await?.execute_query($down).await.map(|_| {}) })
42            }
43        }
44    };
45}