Skip to main content

Module migrations

Module migrations 

Source
Expand description

Schema migrations: SurrealQL files applied in order.

Each migration is a .surql file in DIR, named <YYYYMMDD_HHMMSS>_<name>.surql so that names sort in the order they were written. A migration runs in one transaction together with its record in the TABLE table, so it is applied completely or not at all, and never twice. Migrations must not contain BEGIN/COMMIT.

Migrations only move forward: to undo one, write another.

Structs§

Migration
A migration file.

Constants§

DIR
Where migrations live, relative to the project root.
TABLE
The table recording applied migrations.

Functions§

applied
The names of the applied migrations, in order.
apply
Applies the pending migrations in dir, in order, and returns their names.
load
Every .surql file in dir, in name order.
reset
Removes every table (with its data), sequence, function, param and analyzer from the database, including the record of applied migrations.
run_cli
The command line of an app’s migrate binary:
status
Each migration in dir and whether it has been applied.