mafw.db.migration

Versioned database schema migration package.

This package implements the single internal migration service (the MigrationManager) that compares the live database against the complete set of discovered MAFwBaseModel subclasses, reports differences, generates reviewable Python migration scripts, tracks a per-database applied-migration history, and applies previously reviewed pending scripts on explicit request.

Two front ends share this one implementation:

  • the mafw db CLI command group (diff, migrate generate, migrate status, migrate up and migrate baseline), and

  • the opt-in SchemaMigrator processor that runs after TableCreator and, by default, generates one migration and deliberately stops the pipeline.

Automatic schema migration is limited to MAFwBaseModel subclasses registered in the global model register (mafw_model_register). Models outside the register are out of scope for automatic diffing and generation.

The public objects live in the focused submodules of this package (for example mafw.db.migration.service, mafw.db.migration.diff and mafw.db.migration.errors). Import them from their submodule so each object has a single canonical documentation target.

Added in version 2.4.

author:

Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)

Modules

backend

Per-backend adaptation and the migration applier.

cli_support

CLI support for migration service connections.

diff

Schema differ comparing discovered models with the live database.

directory

Migration-directory resolution and exclusive locking.

discovery

Model discovery for the migration service.

errors

Migration-specific exception hierarchy.

history

Per-database migration history.

outcome

Structured result returned by every migration-service operation.

runtime

Runtime helpers used by generated migration scripts.

script

Migration-script representation, naming, rendering and safe writing.

service

The single internal migration service.