Skip to main content

Module migration

Module migration 

Source
Expand description

Schema migrations for the local Turso database.

A migration is a type implementing Migration: up returns the SQL that applies it and down optionally returns SQL that reverts it. Migrations are listed with the migrations! macro and executed by a Migrator, which records each applied migration with its batch number in the TABLE tracking table.

Every migration runs inside its own transaction together with its tracking row, so a failing migration leaves neither schema changes nor a record behind. Turso, like SQLite, supports transactional DDL; statements that cannot run in a transaction (such as VACUUM) must opt out through Migration::transactional.

Modules§

console
Command-line front end for the migration engine.

Structs§

Failure
A migration that failed. Its tracking record was not written (or removed).
Migrator
Runs, inspects and rolls back migrations on a single connection.
Outcome
A migration that completed successfully.
Registered
A migration paired with its unique name, which also determines run order.
RollbackReport
Result of Migrator::rollback.
RunReport
Result of Migrator::run.
Schema
An ordered list of SQL statements produced by a migration.
Status
One row of Migrator::status.

Enums§

State
Where a migration stands relative to the database.

Constants§

TABLE
Name of the table that records applied migrations.

Traits§

Migration
A single schema change.

Functions§

drop_all_tables
Drops every view and table except SQLite’s and libSQL’s own (indexes and triggers go with their tables). Used by migrate fresh and by tests.