Struct sql_migration_sim::Schema
source · pub struct Schema {
pub dialect: Box<dyn Dialect>,
pub tables: HashMap<String, Table>,
pub views: HashMap<String, View>,
pub indices: HashMap<String, String>,
pub functions: HashMap<String, Function>,
pub creation_order: Vec<ObjectNameAndType>,
}
Expand description
The database schema, built from parsing one or more SQL statements.
Fields§
§dialect: Box<dyn Dialect>
The SQL dialect used for pasing
tables: HashMap<String, Table>
The tables in the schema
views: HashMap<String, View>
The views in the schema
indices: HashMap<String, String>
The created indices. The key is the index name and the value is the table the index is on.
functions: HashMap<String, Function>
Functions in the schema
creation_order: Vec<ObjectNameAndType>
References to the schema objects, in the order they were created.
Implementations§
source§impl Schema
impl Schema
sourcepub fn new_with_dialect<D: Dialect>(dialect: D) -> Self
pub fn new_with_dialect<D: Dialect>(dialect: D) -> Self
Create a new Schema that parses with the given SQL dialect
sourcepub fn apply_statement(&mut self, statement: Statement) -> Result<(), Error>
pub fn apply_statement(&mut self, statement: Statement) -> Result<(), Error>
Apply a parsed statement to the schema
sourcepub fn parse_sql(&self, sql: &str) -> Result<Vec<Statement>, Error>
pub fn parse_sql(&self, sql: &str) -> Result<Vec<Statement>, Error>
Parse some SQL into a list of statements
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schema
impl !RefUnwindSafe for Schema
impl !Send for Schema
impl !Sync for Schema
impl Unpin for Schema
impl !UnwindSafe for Schema
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more