Skip to main content

Module migrate

Module migrate 

Source
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§

AppliedMigration
A row from _resolute_migrations: a migration that has been applied.
Migration
A migration file pair on disk.
StatusReport
Combined view of on-disk files and applied rows, as used by status.
ValidateReport
Result of validate: how the on-disk state compares to the tracking table.

Functions§

create
Create a new {timestamp}_{name}.up.sql / .down.sql pair under dir. Returns the paths to the newly-written up and down files. The timestamp is YYYYMMDDHHMMSS in UTC.
info
List the pending migrations (ones in dir that are not in the tracking table).
revert
Revert the most recently applied migration. Returns the reverted migration, or None when 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 dir for {version}_{name}.up.sql files and return a sorted Vec. 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.