Skip to main content

Crate persistant_migrate

Crate persistant_migrate 

Source
Expand description

The logic behind the persistant-migrate command: reading a directory of migrations and comparing it with a database ledger. The commands themselves are in main.rs.

A directory holds NNN_name.up.sql files (with NNN_name.down.sql partners) or plain NNN_name.sql. The ledger is sqlx’s own _sqlx_migrations, so a database can be handled by this tool or by sqlx migrate run interchangeably. Down files are read and checked for pairing, never run: Migrates has no undo.

Structs§

Line
One line of a status report.
Target
Where a database URL points, as it is safe to print: the password is dropped.

Enums§

LoadError
Why a directory could not be turned into migrations.
State
Where one migration stands against a database.

Functions§

checksum
The checksum the ledger holds for m: SHA-384 of its text.
describe_target
Describe url. A URL that cannot be read is reported as not local, so the guard errs closed.
load_dir
The migrations in dir, in version order. Each down file must pair with an up file.
snapshot_from_files
A snapshot read from the migration files alone, with no database: the migrations’ text, in version order, is read as DDL in dialect (postgres, mysql, mariadb or sqlite) by UniSQL’s schema_from_ddl. Returns the snapshot and the statements UniSQL could not read (head and reason); a skipped statement can only leave a column unregistered, never invent one.
status
Compare migrations with the ledger rows (version, checksum).