toasty_core/schema/db/
migration.rs1pub enum Migration {
3 Sql(String),
4}
5
6impl Migration {
7 pub fn new_sql(sql: String) -> Self {
9 Migration::Sql(sql)
10 }
11
12 pub fn new_sql_with_breakpoints<S: AsRef<str>>(statements: &[S]) -> Self {
15 let sql = statements
16 .iter()
17 .map(|s| s.as_ref())
18 .collect::<Vec<_>>()
19 .join("\n-- #[toasty::breakpoint]\n");
20 Migration::Sql(sql)
21 }
22
23 pub fn statements(&self) -> Vec<&str> {
25 match self {
26 Migration::Sql(sql) => sql.split("\n-- #[toasty::breakpoint]\n").collect(),
27 }
28 }
29}
30
31pub struct AppliedMigration {
33 id: u64,
34}
35
36impl AppliedMigration {
37 pub fn new(id: u64) -> Self {
38 Self { id }
39 }
40
41 pub fn id(&self) -> u64 {
42 self.id
43 }
44}