Skip to main content

Module migration_runner

Module migration_runner 

Source
Expand description

Migration runner for ModKit modules.

This module provides a secure migration execution system that:

  • Executes module-provided migrations using a per-module migration history table.
  • Does not expose raw database connections or SQLx pools to modules.
  • Ensures deterministic, idempotent migration execution.

§Per-Module Migration Tables

Each module gets its own migration history table named modkit_migrations__<prefix>__<hash8>, where <hash8> is an 8-character hex hash derived from the module prefix via xxh3_64. This prevents conflicts between modules that might have similarly named migrations.

Examples:

  • Test prefix “_test” → modkit_migrations___test__e5f6a7b8

§Security Model

Modules only provide migration definitions via MigrationTrait. The runtime executes them using its privileged connection. Modules never receive raw database access.

Structs§

MigrationResult
Result of a migration run.

Enums§

MigrationError
Errors that can occur during migration execution.

Functions§

get_pending_migrations
Check if migrations are pending for a module without applying them.
run_migrations_for_module
Run migrations for a specific module using a Db.
run_migrations_for_testing
Run migrations for testing purposes.