pub async fn migrate(
pool: &PgPool,
dir: &Path,
) -> Result<Vec<Migration>, MigrateError>Expand description
Ensure the ledger table exists, then apply every pending migration
in dir (lex-sorted by name) to pool. Already-applied migrations
are skipped.
Each migration runs in its own transaction unless its atomic
field is false (e.g. for CREATE INDEX CONCURRENTLY). On
failure within an atomic migration the file’s changes roll back
cleanly; prior files stay applied (their commits already
happened), so re-running migrate after fixing the offender will
pick up where it left off.
Returns the migrations that were newly applied (could be empty).
§Errors
Returns MigrateError::Io/MigrateError::Json/MigrateError::Validation
for file problems, MigrateError::Driver for SQL failures.