Skip to main content

Module migration

Module migration 

Source
Expand description

Schema migration tools for SQLite databases

This module provides tools for managing database schema migrations that are stored within the database itself, enabling agents to evolve schemas over time.

§Design

Migrations are stored in a _schema_migrations table within each database:

  • version: Timestamp-based unique identifier (auto-generated)
  • name: Human-readable description
  • sql: The DDL to execute
  • applied_at: When the migration was applied (NULL = pending)
  • checksum: SHA256 of the SQL for integrity

§Tools

Re-exports§

pub use export::ExportMigrationsTool;
pub use import::ImportMigrationsTool;
pub use types::Migration;
pub use types::MigrationStatusFilter;

Modules§

export
Export migrations tool
import
Import migrations tool
types
Types for migration management

Structs§

AddMigrationTool
Adds a new pending migration to the database
GetMigrationTool
Gets details of a specific migration including its SQL
ListMigrationsTool
Lists all migrations with their status
RemoveMigrationTool
Removes a pending migration from the database
RunMigrationsTool
Runs all pending migrations in version order

Constants§

MIGRATIONS_TABLE
The name of the migrations table

Functions§

compute_checksum
Computes SHA256 checksum of SQL content
ensure_migrations_table
Ensures the migrations table exists in the database
generate_version
Generates a version string based on current timestamp