mfd migrate
mfd migrate applies migrations/*.sql next to mfd.yml. Each file is one atomic ALTER TABLE batch. Mfd records the file in the Manifold Store journal family so a retry is idempotent: the same id and checksum is a no-op, a changed file with the same id fails closed.
Python authors those files; migrate never loads .py. Declared transform.compute type: py does load the file in path. Session.migrate() is the same path as the CLI.
You do not stop the pipeline. Apply is in-stream. DISABLE PIPELINE still freezes ingest; it is not the ALTER gate.
Usage
mfd migrate --pipeline <NAME> [--down] [--config <path>] [--log [LEVEL]]Options
| Flag | Default | Description |
|---|---|---|
-p, --pipeline <NAME> | None | Pipeline whose migrations/ apply. Required in practice when several pipelines share a config. |
--down | Off | Apply -- migrate:down instead of -- migrate:up. Only Rename may have a down section. |
See CLI overview for global flags (--config, --store-type, --wal-storage, …).
Examples
Apply pending files, then sync:
mfd migrate --pipeline bikehire
mfd sync --pipeline bikehire --onceRoll back a Rename with --down:
mfd migrate --pipeline bikehire --downAuthor a file
from mfd import Migration
Migration(
"20261020_rename_region",
up="ALTER TABLE bikehire.trips RENAME COLUMN region TO region_code;",
down="ALTER TABLE bikehire.trips RENAME COLUMN region_code TO region;",
).write("migrations")Files use -- migrate:up (optional) and -- migrate:down (optional, Rename only).
-- migrate:up
ALTER TABLE bikehire.trips RENAME COLUMN region TO region_code;
-- migrate:down
ALTER TABLE bikehire.trips RENAME COLUMN region_code TO region;down() is only valid for Rename. Promote, Drop, and Merge fail closed if a -- migrate:down section is present.
Query ALTER
mfd query --sql "ALTER TABLE …" uses the same apply path. Mfd journals it as query-<checksum> in Manifold Store, so repeating the same statement is safe.
Prefer files in migrations/ for anything you want in git. Use query ALTER for a one-off.
What apply does
For each pending file, Mfd:
- Loads the journal from Manifold Store under the writer lock.
- Rewrites live WAL so later ingest uses the new names and types.
- Applies table DDL on destinations that advertise it (Iceberg: ManifoldLake, Athena Iceberg, DuckDB; plus Snowflake, Postgres, BigQuery, Redshift, MotherDuck). Glue/Hive and ClickHouse fail closed.
- Appends the ALTER output log (
schemafamily) and commits the journal row (id, checksum, phase). Source discover metadata is unchanged. A crash mid-apply resumes from that phase; it does not double-apply a finished file.
Iceberg keeps the field id, so existing Parquet stays readable after rename.
Statements: RENAME COLUMN, MERGE COLUMN, DROP COLUMN, ALTER COLUMN … TYPE. TO is one identifier; a dotted TO such as detail.region fails closed. See ALTER operations for the matrix and fail-closed cases.
Manifold Store
Migrations do not use a second KV. Journal, schema, and WAL catalog share Manifold Store with ingest. One writer. See Manifold Store.
