BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Bittern · Decide whether the next database migration can run

Plan the next migration only after history, fingerprints and dirty state agree.

Decide whether the next database migration can run

A version number can match even when a previous migration changed. Check the applied prefix and recorded fingerprints before planning the next step. The two applied versions form an exact prefix with matching fingerprints. Version 5 is ready to apply.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-bittern.git
cd blyx-bittern
blyxc native-run project.blyx -- "1,2,5" "1,2" "10,20" "10,20" 0

API and return values

Returns [can apply next, next available version, pending count, changed fingerprints]. This preflight consumes an exported history and executes no SQL. Invalid input returns an empty vector.

ArgumentAccepted input
availableVector of: nonnegative exact integer
appliedVector of: nonnegative exact integer
expectedVector of: nonnegative exact integer
actualVector of: nonnegative exact integer
dirtynonnegative exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
1
5
1
0
Open in the full playground →

Practice

Change available = [1, 2], applied = [1], expected = [4], actual = [7]. Predict the result, then run the program.

Hint

Returns [can apply next, next available version, pending count, changed fingerprints]. This preflight consumes an exported history and executes no SQL.

Worked solution

The result vector is [0, 2, 1, 1]. Compare its fields with the return layout in the API section.

Find

    let available = [1, 2, 5];

Replace with

    let available = [1, 2];

Find

    let applied = [1, 2];

Replace with

    let applied = [1];

Find

    let expected = [10, 20];

Replace with

    let expected = [4];

Find

    let actual = [10, 20];

Replace with

    let actual = [7];

Output after the change

0
2
1
1