Ordered SQL migrations with a version table for lakehouse storage
Project description
lakemigrate
Ordered SQL migrations with a version table for Delta lakehouse storage.
lakemigrate discovers SQL files in a directory, applies any that have not yet run — in version order — and records each in a Delta history table. Checksums guard against silent edits after a migration has been applied.
Installation
Managed Spark environment (Databricks, EMR, GCP Dataproc — Spark is already present):
pip install lakemigrate
Local development (installs PySpark and delta-spark):
pip install "lakemigrate[spark]"
Migration files
Name each file NNN__description.sql where NNN is a zero-padded three-digit version number:
migrations/
001__create_events_table.sql
002__add_user_id_column.sql
003__backfill_legacy_data.sql
Files are applied in version order. Once applied, the file content is checksummed — modifying a file after it runs raises ChecksumMismatchError.
CLI
# apply all pending migrations
lakemigrate migrate --migrations-dir migrations/
# custom history table
lakemigrate migrate --migrations-dir migrations/ --history-table mydb.schema_history
Python API
from lakemigrate import migrate
# uses default history table: default.lakemigrate_history
migrate("migrations/")
# custom history table
migrate("migrations/", history_table="mydb.schema_history")
A SparkSession must be active before calling migrate. The history table is created automatically on first run.
Error handling
| Exception | When |
|---|---|
InvalidFilenameError |
A file does not match NNN__description.sql |
DuplicateVersionError |
Two files share the same version number |
ChecksumMismatchError |
An applied migration file has been modified |
All exceptions inherit from LakeMigrateError.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lakemigrate-0.1.0.tar.gz.
File metadata
- Download URL: lakemigrate-0.1.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ae57e2fba704627aab958ac8bb9b6916d20e1956fdaeccfcada9a2abf54083d
|
|
| MD5 |
0eea09e8237c022894b36db59c73646f
|
|
| BLAKE2b-256 |
d76636b9c0d5fac206df8aaa9880f3ca9ced7106441cc9d2fabea75f1d925934
|
Provenance
The following attestation bundles were made for lakemigrate-0.1.0.tar.gz:
Publisher:
publish.yml on nicobc/lakemigrate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lakemigrate-0.1.0.tar.gz -
Subject digest:
7ae57e2fba704627aab958ac8bb9b6916d20e1956fdaeccfcada9a2abf54083d - Sigstore transparency entry: 1720930071
- Sigstore integration time:
-
Permalink:
nicobc/lakemigrate@c59bd7f62956811fba8f0517659de04c0f0d48b0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nicobc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c59bd7f62956811fba8f0517659de04c0f0d48b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lakemigrate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lakemigrate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a72fbac0d6f47992198b5da10a7e5a76a14977c7d708e490d18e68cae999059d
|
|
| MD5 |
4e6b28443886c90d239967af96305f9e
|
|
| BLAKE2b-256 |
f851a889b8457fec57d54dcb5d4dc61821b76bc93911472cf442468fd189a180
|
Provenance
The following attestation bundles were made for lakemigrate-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on nicobc/lakemigrate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lakemigrate-0.1.0-py3-none-any.whl -
Subject digest:
a72fbac0d6f47992198b5da10a7e5a76a14977c7d708e490d18e68cae999059d - Sigstore transparency entry: 1720930183
- Sigstore integration time:
-
Permalink:
nicobc/lakemigrate@c59bd7f62956811fba8f0517659de04c0f0d48b0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nicobc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c59bd7f62956811fba8f0517659de04c0f0d48b0 -
Trigger Event:
push
-
Statement type: