pub enum Migration {
Sql(String),
}
impl Migration {
pub fn new_sql(sql: String) -> Self {
Migration::Sql(sql)
}
pub fn new_sql_with_breakpoints<S: AsRef<str>>(statements: &[S]) -> Self {
let sql = statements
.iter()
.map(|s| s.as_ref())
.collect::<Vec<_>>()
.join("\n-- #[toasty::breakpoint]\n");
Migration::Sql(sql)
}
pub fn statements(&self) -> Vec<&str> {
match self {
Migration::Sql(sql) => sql.split("\n-- #[toasty::breakpoint]\n").collect(),
}
}
}
pub struct AppliedMigration {
id: u64,
}
impl AppliedMigration {
pub fn new(id: u64) -> Self {
Self { id }
}
pub fn id(&self) -> u64 {
self.id
}
}