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.
- Migration
File - A migration and the file it was read from.
- Plan
- Qualified
Name - 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§
Constants§
- HISTORY_
DDL - refinery’s DDL;
%Tstands 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_onof 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
i32and 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
tableunless it exists. - history_
version - A migration’s version as the history’s
INT4holds it. A version the column cannot hold is refused before a run is planned. - interrupted_
builds - The invalid indexes of the schema that
sqlnames: 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, whereDefaultHasheris 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
appliedagainst thelocalfiles and list what is left to apply. An applied version abovebaselinemust 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
namewithinnamespace. - platform_
lock_ key - The key of a history only this platform’s runners write.
- record_
statement - Records a migration in
history, takingversion,name,applied_onandchecksum. - scan_
dir - The migrations of
dir, ascending, each with the exact text of its file. - scan_
files - The migration files of
dir, ascending. Every.sqlfile there is a migration; anything else is left alone.