pub struct MigrationConfig {
pub path: PathBuf,
pub prefix_style: MigrationPrefixStyle,
pub flavor: Option<Flavor>,
pub table_name_prefix: Option<String>,
}Expand description
Configuration for migration operations.
Controls where migration files, snapshot files, and the history file are stored, how migration file names are prefixed (sequential numbers or timestamps), and which database flavor migrations target by default.
All paths are relative to the target package’s directory.
§Examples
use toasty_cli::{MigrationConfig, MigrationPrefixStyle};
let config = MigrationConfig::new()
.path("my_app/db")
.prefix_style(MigrationPrefixStyle::Timestamp);
assert_eq!(
config.get_migrations_dir(),
std::path::PathBuf::from("my_app/db/migrations"),
);
assert_eq!(
config.get_snapshots_dir(),
std::path::PathBuf::from("my_app/db/snapshots"),
);
assert_eq!(
config.get_history_file_path(),
std::path::PathBuf::from("my_app/db/history.toml"),
);Fields§
§path: PathBufPath to the migrations folder
prefix_style: MigrationPrefixStyleStyle of migration file prefixes
flavor: Option<Flavor>Database flavor migrations target when --flavor is not passed.
table_name_prefix: Option<String>Prefix applied to every table name when the schema is extracted. Must
match Db::builder().table_name_prefix(..), which the extraction
constructor runs too early to observe.
Implementations§
Source§impl MigrationConfig
impl MigrationConfig
Sourcepub fn prefix_style(self, style: MigrationPrefixStyle) -> Self
pub fn prefix_style(self, style: MigrationPrefixStyle) -> Self
Set the migration prefix style
Sourcepub fn table_name_prefix(self, prefix: impl Into<String>) -> Self
pub fn table_name_prefix(self, prefix: impl Into<String>) -> Self
Set the table name prefix the extracted schema is lowered with
Sourcepub fn get_migrations_dir(&self) -> PathBuf
pub fn get_migrations_dir(&self) -> PathBuf
Returns the directory of the migration files derived from path.
Sourcepub fn get_snapshots_dir(&self) -> PathBuf
pub fn get_snapshots_dir(&self) -> PathBuf
Returns the directory of the snapshot files derived from path.
Sourcepub fn get_history_file_path(&self) -> PathBuf
pub fn get_history_file_path(&self) -> PathBuf
Get the path to the history file
Trait Implementations§
Source§impl Clone for MigrationConfig
impl Clone for MigrationConfig
Source§fn clone(&self) -> MigrationConfig
fn clone(&self) -> MigrationConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MigrationConfig
impl Debug for MigrationConfig
Source§impl Default for MigrationConfig
impl Default for MigrationConfig
Source§impl<'de> Deserialize<'de> for MigrationConfig
impl<'de> Deserialize<'de> for MigrationConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for MigrationConfig
impl PartialEq for MigrationConfig
Source§fn eq(&self, other: &MigrationConfig) -> bool
fn eq(&self, other: &MigrationConfig) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MigrationConfig
impl Serialize for MigrationConfig
impl StructuralPartialEq for MigrationConfig
Auto Trait Implementations§
impl Freeze for MigrationConfig
impl RefUnwindSafe for MigrationConfig
impl Send for MigrationConfig
impl Sync for MigrationConfig
impl Unpin for MigrationConfig
impl UnsafeUnpin for MigrationConfig
impl UnwindSafe for MigrationConfig
Blanket Implementations§
§impl<T> Assign<Json<T>> for Twhere
T: Serialize,
impl<T> Assign<Json<T>> for Twhere
T: Serialize,
§fn into_assignment(self) -> Assignment<Json<T>>
fn into_assignment(self) -> Assignment<Json<T>>
Assignment<T>] value.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more