SchemaMgr

Trait SchemaMgr 

Source
pub trait SchemaMgr {
    // Provided methods
    fn init(&self, conn: &mut Connection, newdb: bool) -> Result<(), Error> { ... }
    fn need_upgrade(&self, conn: &Connection) -> Result<bool, Error> { ... }
    fn upgrade(&self, conn: &mut Connection) -> Result<(), Error> { ... }
}
Available on crate feature sqlsrv only.
Expand description

Used to register application callbacks to set up database schema.

Provided Methods§

Source

fn init(&self, conn: &mut Connection, newdb: bool) -> Result<(), Error>

Called just after the writer connection has been created and is intended to perform database initialization (create tables, add predefined rows, etc).

newdb will be true if the database file did not exist prior to initialization.

While this method can be used to perform schema upgrades, there are two specialized methods (need_upgrade() and upgrade()) that can be used for this purpose instead.

The default implementation does nothing but returns Ok(()).

§Errors

Application-specific error.

Source

fn need_upgrade(&self, conn: &Connection) -> Result<bool, Error>

Application callback used to determine if the database schema is out of date and needs to be updated.

The default implementation does nothing but returns Ok(false).

§Errors

Application-specific error.

Source

fn upgrade(&self, conn: &mut Connection) -> Result<(), Error>

Upgrade the database schema.

This is called if SchemaMgr::need_upgrade() returns Ok(true).

The default implementation does nothing but returns Ok(()).

§Errors

Application-specific error.

Implementors§