pub use tosin_macros::gather_migrations as gather; use diesel::{Connection, result::Error as DieselError}; use crate::db::backend::Connectable; mod change; pub use change::*; pub struct Migration { pub id: usize, pub name: &'static str, pub prereqs: &'static [(&'static str, usize)], pub changes: &'static [DatabaseChange], } impl Migration { pub fn apply(&self, app_name: &str, connection: &C::Connection) { // TODO prevent double-applying connection.transaction::<_, DieselError, _>(|| { for change in self.changes { change.apply::(app_name, connection); } Ok(()) }).unwrap(); } }