Skip to main content

Crate cufflink_migrate

Crate cufflink_migrate 

Source
Expand description

SQL migrations of a service: which files a directory holds, what a history table records, and what is left to apply. Checksums, the history table and the rows written to it are refinery’s, so a history refinery began is continued and refinery reads one begun here.

Nothing here touches a database; the runners that do share these rules.

Structs§

Applied
A row of the history table.
MigrationFile
A migration and the file it was read from.
Plan
QualifiedName
A table and the schema it is in, both as Postgres stores them: what a statement quotes and what a session resolves unquoted are one table.
Standing
The transaction and the role statements run in.
Timeouts
How long a run waits for its lock and how long its statements may take.

Enums§

Escape
How a migration left what the runner ran it in.
PlanError
ScanError

Constants§

HISTORY_DDL
refinery’s DDL; %T stands for the table.
INVALID_INDEXES
The invalid indexes of a schema, taking its folded name.
STANDING
The transaction and the role statements run in now, answered as Standing’s two fields.
TRY_LOCK
Takes the run’s advisory lock if it is free, answering whether it did.
UNLOCK

Functions§

applied_on_now
The applied_on of a migration applied now: RFC 3339 in UTC, as refinery writes it.
applied_rows
The rows of history: version, name, applied_on, checksum, as text but the version, in version order.
checksum
refinery’s checksum of a migration: SipHash-1-3 over its name, its version as an i32 and its SQL, so a history either runner wrote verifies under the other.
escaped
Why a migration that escaped is refused rather than recorded.
history_ddl
The statement that creates table unless it exists.
history_version
A migration’s version as the history’s INT4 holds it. A version the column cannot hold is refused before a run is planned.
interrupted_builds
The invalid indexes of the schema that sql names: a concurrent build the last attempt left unfinished, which would make this attempt fail.
legacy_table_lock_key
The key a legacy refinery runner takes for table: (DefaultHasher(table).finish() as i64).abs() % i64::MAX, where DefaultHasher is SipHash-1-3 with zero keys. Sharing it keeps that runner and this one from touching one history at once.
lock_key
The key of the advisory lock a run holds on history.
parse_applied
A history row read with every column but the version as nullable text. A row refinery could not have written is refused, where refinery’s own driver panics.
plan
Check applied against the local files and list what is left to apply. An applied version above baseline must have its local file, unchanged; one at or under it is accepted as it is.
platform_key
The key of a lock only this platform’s processes take, on name within namespace.
platform_lock_key
The key of a history only this platform’s runners write.
record_statement
Records a migration in history, taking version, name, applied_on and checksum.
scan_dir
The migrations of dir, ascending, each with the exact text of its file.
scan_files
The migration files of dir, ascending. Every .sql file there is a migration; anything else is left alone.