The tool identifies bugs capable of silently corrupting or breaking pipelines before deploying to production, with a simple concept: you create a "contract" describing exactly how your database should look. Before running any pipeline, the tool compares the actual database against this contract and warns you (or blocks you) if anything has changed.
Consult the documentation: driftbrake.pages
DriftBrake
DriftBrake runs before pipelines execute, verifying that the actual database still respects the contract expected by its data consumers. It detects deviations, classifies impact, and blocks execution when necessary — but never alters the database. DriftBrake is not a migration tool. It doesn't apply changes to the database, doesn't generate SQL scripts, and doesn't manage schema versions.
Python package
This package was designed to run before your pipelines; future updates will expand compatibility to other databases and file formats.
This README contains only basic information related to installing DriftBrake via pip. This package is experimental and may change in future versions. DriftBrake can be used through the CLI or (to customize detection policies) implemented directly in code — see the build instructions in "Python API".
The Python package for DriftBrake automatically reads the current schema of a PostgreSQL database, compares it against a versioned contract, classifies drifts by impact, and can block pipelines before they break in production.
NOTE: If you are using this with a database other than PostgreSQL (MySQL, SQLite, SQL Server, etc.) you may encounter unexpected errors. In the current version DriftBrake is built entirely around PostgreSQL semantics: the schema reader queries information_schema.schemata and reads index options exclusive to Postgres (postgresql_using, postgresql_where), and the type compatibility matrix follows PostgreSQL cast rules (varchar, text, bigint, timestamptz, etc.). Other databases are not supported yet.
Installation
# Installs the psycopg2-binary driver, required for the postgres connection
pip install "driftbrake[postgres]"
# Install pyarrow
pip install "driftbrake[parquet]"
For Parquet files, see the parquet tutorial
The
[dev]extra includespre-commit,ruff,mypy,pytest, and the other development tools.
How it works
The current flow:
schema.lock.json (contract versioned in Git)
│
▼
DriftBrake connects to PostgreSQL
│
▼
reads the current schema automatically
│
▼
compares expected against current
│
├── OK ──────────────────── pipeline runs
│
└── BREAKING ────────────── pipeline blocked
├── displays in terminal
├── generates schema_diff.json
└── generates schema_report.html
Change types detected
The tool detects the following categories of change in every comparison:
| Type | What it means |
|---|---|
table_added |
A new table appeared in the database |
table_removed |
A table that existed is gone from the database |
column_added |
A NOT NULL column was added to an existing table |
nullable_column_added |
A nullable column was added to an existing table |
column_removed |
A column was removed from an existing table |
type_changed |
A column's data type changed (e.g. INTEGER → TEXT) |
nullable_changed |
The column stopped accepting NULL or started accepting it |
default_changed |
The column's default value changed or was removed |
primary_key_changed |
A column gained or lost its primary key |
unique_changed |
A UNIQUE constraint was added or removed |
foreign_key_changed |
A foreign key was modified |
foreign_key_added |
A foreign key was created where there was none |
ordinal_position_changed |
The column's position in the table changed |
possible_rename |
A column was removed and a similar one was added in the same table. The tool only flags this as a suspicion of rename, never as a confirmation. Always classified as WARNING. |
possible_renameis a heuristic, never a confirmation. DriftBrake flags the suspicion when a removed column and an added column appear type-compatible. Final validation must be done by whoever reviews the migration.
possible_rename confidence
Each possible_rename occurrence carries a confidence field indicating how certain the heuristic is:
| Level | Criteria |
|---|---|
high |
Similar name + same type + close ordinal position (difference ≤ 2) |
medium |
Same type + close ordinal position (difference ≤ 2) |
low |
Only type-compatible (SAFE or WARNING in the type matrix) |
Important rules:
possible_renameis never automatically classified asBREAKING— alwaysWARNING.- A
confidence: "high"is still a suspicion, not a certainty. - Always review migrations before accepting a rename with
driftbrake update-contract.
License
MIT license
Metadata
Release files for driftbrake 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| driftbrake-0.3.0.tar.gz | 54.4 kB | Without provenance | Details for driftbrake-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| driftbrake-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for driftbrake-0.3.0-py3-none-any.whl |
Total release size: 128.6 kB
Release files / driftbrake-0.3.0.tar.gz
| Download URL | driftbrake-0.3.0.tar.gz |
|---|---|
| Size | 54.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea35554f0c4e89d3d623060ea25cfd6e98e03db141a3f1f8be1fe74b3648da9e
|
|
BLAKE2b-256 checksum How to use checksums |
6f5c8fd02dcd8a99049ab8c21fe8be3ed002176cf9237802dd1c553d15ddabb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / driftbrake-0.3.0-py3-none-any.whl
| Download URL | driftbrake-0.3.0-py3-none-any.whl |
|---|---|
| Size | 74.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
532d92fc7509dce624be6e6d7ec112829a737dcce38193c231c66153be186c0e
|
|
BLAKE2b-256 checksum How to use checksums |
fc82893e36cbaaf02983e1b7c9d2f6b289864e0d90e4ed910fbccfae92b56eee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for driftbrake 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.