safe_migrate/engine/
mod.rs1#![allow(clippy::module_inception)]
3
4pub mod config;
5pub mod engine;
6
7use squawk_syntax::ast::SourceFile;
8use squawk_syntax::ast::Stmt;
9
10pub struct MigrationFile {
13 source: SourceFile,
14}
15
16impl MigrationFile {
17 pub fn parse(sql: &str) -> Result<Self, Vec<String>> {
18 let parsed = SourceFile::parse(sql);
19 let errors: Vec<String> = parsed.errors().iter().map(|e| e.to_string()).collect();
20
21 if !errors.is_empty() {
22 return Err(errors);
23 }
24
25 Ok(Self {
26 source: parsed.tree(),
27 })
28 }
29
30 pub fn statements(&self) -> impl Iterator<Item = Stmt> + '_ {
31 self.source.stmts()
32 }
33}