pub struct Builder { /* private fields */ }Expand description
Builder for configuring migration and seed discovery at compile time.
This builder allows you to customize the directories where migrations and seeds
are located. By default, it looks for migrations in migrations/ and seeds in src/seeds/.
§Example in build.rs
// Use defaults (migrations/ and src/seeds/)
// If either directory doesn't exist, it will be skipped automatically
ic_sql_migrate::Builder::new().build().unwrap();
// Custom directories
ic_sql_migrate::Builder::new()
.with_migrations_dir("db/migrations")
.with_seeds_dir("src/db/seeds")
.build()
.unwrap();Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with default settings.
Defaults:
- Migrations directory:
migrations/ - Seeds directory:
src/seeds/
Sourcepub fn with_migrations_dir(self, dir: impl Into<String>) -> Self
pub fn with_migrations_dir(self, dir: impl Into<String>) -> Self
Sets the directory where migration SQL files are located.
§Arguments
dir- Path relative toCargo.toml
Sourcepub fn with_seeds_dir(self, dir: impl Into<String>) -> Self
pub fn with_seeds_dir(self, dir: impl Into<String>) -> Self
Sourcepub fn build(self) -> Result<()>
pub fn build(self) -> Result<()>
Executes the builder, discovering and generating code for migrations and seeds.
This method automatically handles missing directories by generating empty arrays. You don’t need to specify whether directories exist or not.
§Errors
Returns an I/O error if file system operations fail or required environment variables are not set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
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