Struct migrant_lib::Config
[−]
[src]
pub struct Config { pub path: PathBuf, // some fields omitted }
Project configuration/settings
Fields
path: PathBuf
Methods
impl Config
[src]
fn use_migrations(
&mut self,
migrations: Vec<Box<Migratable>>
) -> Result<&mut Self>
[src]
&mut self,
migrations: Vec<Box<Migratable>>
) -> Result<&mut Self>
Define an explicit set of Migratable
migrations to use.
When using explicit migrations, make sure they are defined on the Config
instance before applied migrations are loaded from the database. This is
required because tag format requirements are stricter for implicit
(file-system based) migrations are stricter, requiring a timestamp to
maintain a deterministic order.
Example
let mut config = Config::load_file_only(&p)?; config.use_migrations(vec![ EmbeddedMigration::with_tag("initial")? .up(include_str!("../migrations/initial/up.sql")) .down(include_str!("../migrations/initial/down.sql")) .boxed(), FileMigration::with_tag("second")? .up("migrations/second/up.sql")? .down("migrations/second/down.sql")? .boxed(), FnMigration::with_tag("custom")? .up(migrations::Custom::up) .down(migrations::Custom::down) .boxed(), ])?; let config = config.reload()?;
fn is_explicit(&self) -> bool
[src]
Migrations are explicitly defined
fn reload(&self) -> Result<Config>
[src]
Do a full reload of the configuration file, keeping track of
manually specified migrations
fn load_file_only<T: AsRef<Path>>(path: T) -> Result<Config>
[src]
Load config file from the given path without querying the database to check for applied migrations
fn load<T: AsRef<Path>>(path: T) -> Result<Config>
[src]
Load config file from the given path and query the database to load up applied migrations
fn init_in(dir: &Path) -> ConfigInitializer
[src]
Start a config initializer in the given directory
fn setup(&self) -> Result<bool>
[src]
- Confirm the database can be accessed
- Setup the database migrations table if it doesn't exist yet
fn migration_dir(&self) -> Result<PathBuf>
[src]
Return the absolute path to the directory containing migration folders
fn database_type(&self) -> Result<String>
[src]
Return the database type
fn database_path(&self) -> Result<PathBuf>
[src]
Return the absolute path to the database file. This is intended for sqlite3 databases only
fn connect_string(&self) -> Result<String>
[src]
Generate a database connection string. Not intended for file-based databases (sqlite)