Skip to main content

Module migrator

Module migrator 

Source
Expand description

Forward-only SQLite migrator for the LinkMarks store.

Each migration is a Migration { version, description, sql } entry in the MIGRATIONS slice. migrate(conn) runs every un-applied migration inside a single transaction and stamps PRAGMA user_version with the final version. Re-running migrate on an up-to-date DB is a no-op.

The migrator does not support downgrades. Forward-only matches the LinkMarks operational model (snapshot + restart beats destructive rollback). Detecting a newer schema than the highest known migration returns CoreError::Storage with a newer schema prefix so callers can surface a clear upgrade error.

Structs§

Migration
One forward migration. sql may contain any number of statements separated by ;. version is monotonically increasing and is stamped into PRAGMA user_version after the migration commits.

Constants§

MAX_SUPPORTED_VERSION
Highest migration version known to this binary. The migrator will reject any DB whose user_version exceeds this constant.
MIGRATIONS
All known migrations. Append-only.
MIGRATION_001_SQL
SQL body for migration version 1. Stored separately so the const initializers above stay readable.

Functions§

applied_versions
Returns the list of versions currently recorded in schema_migrations.
current_user_version
Read the current PRAGMA user_version from the connection.
migrate
Run every un-applied migration in a single transaction and stamp PRAGMA user_version with the final version.