Expand description
Migration runner for use in applications, build scripts, and tooling.
The primary entry point is run, which applies every pending migration
from a directory of {version}_{name}.up.sql / .down.sql file pairs.
Companion helpers (create, revert, status, info, validate,
seed) mirror what resolute-cli migrate ... exposes: the CLI is a thin
presentation layer on top of these functions.
// In main.rs or startup code:
resolute::migrate::run("postgres://user:pass@localhost/db", "migrations").await?;Structs§
- Applied
Migration - A row from
_resolute_migrations: a migration that has been applied. - Migration
- A migration file pair on disk.
- Status
Report - Combined view of on-disk files and applied rows, as used by
status. - Validate
Report - Result of
validate: how the on-disk state compares to the tracking table.
Functions§
- create
- Create a new
{timestamp}_{name}.up.sql/.down.sqlpair underdir. Returns the paths to the newly-written up and down files. The timestamp isYYYYMMDDHHMMSSin UTC. - info
- List the pending migrations (ones in
dirthat are not in the tracking table). - revert
- Revert the most recently applied migration. Returns the reverted migration,
or
Nonewhen nothing has been applied. - run
- Run all pending migrations. Returns the list of migrations newly applied, in the order they ran. Each migration runs in its own transaction.
- scan_
migrations - Scan
dirfor{version}_{name}.up.sqlfiles and return a sortedVec. Directories that don’t exist return an empty list rather than erroring. - seed
- Apply a seed SQL file against the target database. Runs as one simple_query.
- status
- Snapshot on-disk files + tracking table rows for presentation.
- validate
- Compare the tracking table to on-disk files and report drift.