Skip to main content

migrate_embedded

Function migrate_embedded 

Source
pub async fn migrate_embedded(
    pool: &PgPool,
    embedded: &[(&str, &str)],
) -> Result<Vec<Migration>, MigrateError>
Expand description

Apply pending migrations from an in-memory &[(name, json)] slice.

Built for deployments where shipping a migrations/ folder alongside the binary is awkward (Docker images, single-binary distribution). Pair with the embed_migrations! proc-macro from rustango-macros (re-exported as rustango::embed_migrations!), which scans a directory at compile time and emits the slice via include_str! per file. The macro emits content in lex-sorted order, but this function re-sorts defensively.

Each entry’s first item must equal the migration’s name field — a divergence would mean the slice was hand-built incorrectly.

§Errors

As migrate, plus MigrateError::Validation when an entry key doesn’t match the migration’s own name.