Skip to main content

Ordered SQL migrations with a version table for lakehouse storage

Project description

lakemigrate

PyPI Python License: MIT CI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lakemigrate-0.1.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lakemigrate-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

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

Hashes for lakemigrate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ae57e2fba704627aab958ac8bb9b6916d20e1956fdaeccfcada9a2abf54083d
MD5 0eea09e8237c022894b36db59c73646f
BLAKE2b-256 d76636b9c0d5fac206df8aaa9880f3ca9ced7106441cc9d2fabea75f1d925934

See more details on using hashes here.

Provenance

The following attestation bundles were made for lakemigrate-0.1.0.tar.gz:

Publisher: publish.yml on nicobc/lakemigrate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for lakemigrate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a72fbac0d6f47992198b5da10a7e5a76a14977c7d708e490d18e68cae999059d
MD5 4e6b28443886c90d239967af96305f9e
BLAKE2b-256 f851a889b8457fec57d54dcb5d4dc61821b76bc93911472cf442468fd189a180

See more details on using hashes here.

Provenance

The following attestation bundles were made for lakemigrate-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nicobc/lakemigrate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page