PostgreSQL migrations, sweetly done ๐
Project description
Confiture ๐
PostgreSQL migrations, sweetly done
Confiture is the official migration tool for FraiseQL, designed with a build-from-scratch philosophy and 4 migration strategies to handle every scenario from local development to zero-downtime production deployments.
Part of the FraiseQL ecosystem - While Confiture works standalone for any PostgreSQL project, it's designed to integrate seamlessly with FraiseQL's GraphQL-first approach.
๐ Part of the FraiseQL Ecosystem
confiture accelerates PostgreSQL schema evolution across the FraiseQL stack:
Server Stack (PostgreSQL + Python/Rust)
| Tool | Purpose | Status | Performance Gain |
|---|---|---|---|
| pg_tviews | Incremental materialized views | Beta | 100-500ร faster |
| jsonb_delta | JSONB surgical updates | Stable | 2-7ร faster |
| pgGit | Database version control | Stable | Git for databases |
| confiture | PostgreSQL migrations | Beta | 300-600ร faster (theoretical) |
| fraiseql | GraphQL framework | Stable | 7-10ร faster |
| fraiseql-data | Seed data generation | Phase 6 | Auto-dependency resolution |
Client Libraries (TypeScript/JavaScript)
| Library | Purpose | Framework Support |
|---|---|---|
| graphql-cascade | Automatic cache invalidation | Apollo, React Query, Relay, URQL |
How confiture fits:
- Build from DDL โ Fresh DB in <1s for fraiseql GraphQL testing
- pgGit automatically tracks confiture migrations
- Manage pg_tviews schema evolution with 4 migration strategies
- fraiseql-data seeds the schema confiture built
Intended workflow:
# Build schema from DDL files
confiture build --env test
# Seed test data
fraiseql-data add tb_user --count 100
# Run GraphQL tests
pytest
Why Confiture?
The Problem with Migration History
Traditional migration tools (Alembic, Django migrations, Flyway) use migration history replay: every time you build a database, the tool executes every migration file in order. This works, but it's slow and brittle:
- Slow: Fresh database builds take 5-10 minutes (replaying hundreds of operations)
- Brittle: One broken migration breaks everything - your database history is fragile
- Complicated: Developers maintain two things: current schema AND migration history
- Messy: Technical debt accumulates as migrations pile up over months/years
The Confiture Approach
Confiture flips the model: DDL source files are the single source of truth. To build a database:
- Read all
.sqlfiles indb/schema/ - Execute them once (in order)
- Done โ
No migration history to replay. No accumulated technical debt. Just your actual, current schema. Fresh databases in <1 second.
Intended Advantages Over Alembic
| Feature | Confiture | Alembic | Notes |
|---|---|---|---|
| Fresh DB setup | Direct DDL execution | Migration replay | Theoretically faster |
| Zero-downtime migrations | Via FDW (planned) | Not built-in | Not yet production-tested |
| Production data sync | Built-in (with PII anonymization) | Not available | Not yet production-tested |
| Schema diffs | Auto-generated | Manual | Implemented |
| Conceptual simplicity | DDL-first | Migration-first | Different philosophy |
What's Implemented
- โ 4 migration strategies (Build from DDL, ALTER, Production Sync, FDW)
- โ Python + optional Rust extension
- โ PII anonymization strategies
- โ Comprehensive test suite (3,200+ tests)
- โ ๏ธ Not yet used in production - Beta software
The Four Mediums
1๏ธโฃ Build from DDL
confiture build --env production
Build fresh database from db/schema/ DDL files in <1 second.
2๏ธโฃ Incremental Migrations (ALTER)
confiture migrate up
Apply migrations to existing database (simple schema changes).
3๏ธโฃ Production Data Sync
confiture sync --from production --anonymize users.email
Copy production data to local/staging with PII anonymization.
4๏ธโฃ Schema-to-Schema Migration (Zero-Downtime)
confiture migrate schema-to-schema --strategy fdw
Complex migrations via FDW with 0-5 second downtime.
Quick Start
Installation
pip install fraiseql-confiture
# Or with FraiseQL integration
pip install fraiseql-confiture[fraiseql]
Initialize Project
confiture init
Creates:
db/
โโโ schema/ # DDL: CREATE TABLE, views, functions
โ โโโ 00_common/
โ โโโ 10_tables/
โ โโโ 20_views/
โโโ seeds/ # INSERT: Environment-specific test data
โ โโโ common/
โ โโโ development/
โ โโโ test/
โโโ migrations/ # Generated migration files
โโโ environments/ # Environment configurations
โโโ local.yaml
โโโ test.yaml
โโโ production.yaml
Build Schema
# Build local database
confiture build --env local
# Build production schema
confiture build --env production
Create Migration
# Edit schema
vim db/schema/10_tables/users.sql
# Generate migration
confiture migrate generate --name "add_user_bio"
# Apply migration
confiture migrate up
Test Migrations Before Applying (Dry-Run)
Analyze migrations without executing them:
# Analyze pending migrations
confiture migrate up --dry-run
# Test in SAVEPOINT (guaranteed rollback)
confiture migrate up --dry-run-execute
# Save analysis to file
confiture migrate up --dry-run --format json --output report.json
# Analyze rollback impact
confiture migrate down --dry-run --steps 2
For more details, see Dry-Run Guide.
Documentation
User Guides
Core Concepts:
- Build from DDL - Execute DDL files directly
- Incremental Migrations - ALTER-based changes
- Production Data Sync - Copy and anonymize data
- Zero-Downtime Migrations - Schema-to-schema via FDW
- Migration Decision Tree - Choose the right strategy
Advanced:
- Dry-Run Mode - Test migrations before applying
- Migration Hooks - Execute custom logic before/after migrations
- Anonymization - PII data masking strategies
- Compliance - HIPAA, SOX, PCI-DSS, GDPR
- Integrations - Slack, GitHub Actions, monitoring
API Reference
- CLI Reference - All commands documented
- Configuration - Environment configuration
- Schema Builder API - Building schemas programmatically
- Migrator API - Migration execution
- Syncer API - Production data sync
- Hook API - Migration lifecycle hooks
- Anonymization API - PII data masking
- Linting API - Schema validation rules
Examples
- Examples Overview - Complete examples
- Basic Migration - Learn the fundamentals
- FraiseQL Integration - GraphQL workflow
- Zero-Downtime - FDW-based migration
- Production Sync - PII anonymization
Features
Core Migration System (Implemented)
- โ Build from DDL (Medium 1) - Execute DDL files directly
- โ Incremental migrations (Medium 2) - ALTER-based changes
- โ Production data sync (Medium 3) - Copy with PII anonymization
- โ Zero-downtime migrations (Medium 4) - Schema-to-schema via FDW
Additional Features (Implemented)
- โ Optional Rust extension for performance
- โ Schema diff detection with auto-generation
- โ CLI with rich terminal output
- โ Multi-environment configuration
- โ Migration hooks (pre/post execution)
- โ Schema linting with multiple rules
- โ PII anonymization strategies
- โ Dry-run mode for testing
Documentation (Comprehensive)
- โ User guides for all 4 migration strategies
- โ API reference documentation
- โ Integration guides (Slack, GitHub Actions, monitoring)
- โ Compliance guides (HIPAA, SOX, PCI-DSS, GDPR)
Comparison
| Feature | Alembic | pgroll | Confiture |
|---|---|---|---|
| Philosophy | Migration replay | Multi-version schema | Build-from-DDL |
| Fresh DB setup | Minutes | Minutes | <1 second |
| Zero-downtime | โ No | โ Yes | โ Yes (FDW) |
| Production sync | โ No | โ No | โ Built-in |
| Language | Python | Go | Python + Rust |
Current Version
v0.3.5
โ ๏ธ Beta Software: Confiture has not yet been used in production. While the codebase includes comprehensive tests and documentation, real-world usage may reveal issues. Use with caution in production environments.
What's Implemented
- โ All 4 migration strategies (Build from DDL, ALTER, Production Sync, FDW)
- โ Comprehensive test suite (3,200+ tests passing)
- โ Documentation and guides
- โ Python 3.11, 3.12, 3.13 support
- โ Optional Rust extension
- โ Migration hooks, schema linting, anonymization strategies
What's NOT Validated
- โ Production usage (never deployed to production)
- โ Performance claims (benchmarks only, not real-world)
- โ Edge cases and failure recovery (not battle-tested)
- โ Large-scale data migrations (theoretical only)
Contributing
Contributions welcome! We'd love your help making Confiture even better.
Quick Start:
# Clone repository
git clone https://github.com/fraiseql/confiture.git
cd confiture
# Install dependencies (includes Rust build)
uv sync --all-extras
# Build Rust extension
uv run maturin develop
# Run tests
uv run pytest --cov=confiture
# Format code
uv run ruff format .
# Type checking
uv run mypy python/confiture/
Resources:
- CONTRIBUTING.md - Contributing guidelines
- CLAUDE.md - AI-assisted development guide
- PHASES.md - Detailed roadmap
What to contribute:
- ๐ Bug fixes
- โจ New features
- ๐ Documentation improvements
- ๐ก New examples
- ๐งช Test coverage improvements
Author
Vibe-engineered by Lionel Hamayon ๐
Confiture was crafted with care as the migration tool for the FraiseQL ecosystem, combining the elegance of Python with the performance of Rust, and the sweetness of strawberry jam.
License
MIT License - see LICENSE for details.
Copyright (c) 2025 Lionel Hamayon
Acknowledgments
- Inspired by printoptim_backend's build-from-scratch approach
- Built for FraiseQL GraphQL framework
- Influenced by pgroll, Alembic, and Reshape
- Developed with AI-assisted vibe engineering โจ
FraiseQL Ecosystem
Confiture is part of the FraiseQL family:
Making jam from strawberries, one migration at a time. ๐โ๐ฏ
Vibe-engineered with โค๏ธ by Lionel Hamayon
Documentation โข GitHub โข PyPI
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 Distributions
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 fraiseql_confiture-0.3.6.tar.gz.
File metadata
- Download URL: fraiseql_confiture-0.3.6.tar.gz
- Upload date:
- Size: 930.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0692454a143006d9c196ffa49387292f4c3ba213735d6e70827adefc1898a80a
|
|
| MD5 |
7119b7c14cf38aa8601113300f5a6b15
|
|
| BLAKE2b-256 |
c17e6ab7df1b7431c4f7bad59f725043f71c107b0d2c0d2f9c8aff3423608cb1
|
File details
Details for the file fraiseql_confiture-0.3.6-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 482.2 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36c57c0f934a24537f478e6027ff7e4e8ad4ee8cfd50703824e45398104c28d4
|
|
| MD5 |
f4e4feda6b7e58b0a837a695e0cc8911
|
|
| BLAKE2b-256 |
bf30e1a5f0d7b59eaa3456ebd3150b3e8f1176f75f92d01e1143c2ede66cf761
|
File details
Details for the file fraiseql_confiture-0.3.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 482.2 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad884008a06e7365f26888227e8b9b9e2a7a5349bfb6d4e8a3ddd7649229a2f2
|
|
| MD5 |
2323143deb56cdccb746fd11b194dfe6
|
|
| BLAKE2b-256 |
dd778843b010da833512da8acc9b804943fe78c2d03d274c27584e2ce50f07ec
|
File details
Details for the file fraiseql_confiture-0.3.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 530.4 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d7ee03d8f0fc1ca92d81aa832282ae387dbaba772ca7908eca1875f2ff1746
|
|
| MD5 |
333851b6a70d1853d60515165852e579
|
|
| BLAKE2b-256 |
79102c827a180b9849c0dea90dfbb201d7acd22a8a3bd5aa03e72c9d6a8513df
|
File details
Details for the file fraiseql_confiture-0.3.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 482.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35647ec9bafedad71d2741af874b9673cc0fbbbef1d6d22da395e495e5224d0d
|
|
| MD5 |
d0a9bc37d3981928a7cc8aefa89efc3f
|
|
| BLAKE2b-256 |
3c78ba94b7736b671cc91f9c0f6477bf8ae0b628b5cc0e01e51e78f43aa1906b
|
File details
Details for the file fraiseql_confiture-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 564.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1e8e9829e9ce1931e4ce39c1382210ffbe87fa59dd924ef0d21c764220b9094
|
|
| MD5 |
a17e30d4f69987a85f1b53e346cef5fb
|
|
| BLAKE2b-256 |
c40e9cb28880c9bdacf630228b703ba4364c9770485ff25daa0139dac11943ef
|
File details
Details for the file fraiseql_confiture-0.3.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 530.4 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b3a010eaaa6bdd89ac66a0748856f61f0b30e3d5ce5b0f2376da5c2b5203f3d
|
|
| MD5 |
f787c787e0eeee01a794dc9a02bcd028
|
|
| BLAKE2b-256 |
2f0bb2589b7e3778eab9e2bc0b8079b5750063ce54ea4c90c33d8ceb67e17380
|
File details
Details for the file fraiseql_confiture-0.3.6-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 482.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ad993a352f6abe05d5aeec7d3c0ba7a578b566d1a2f21473f03c58f3a2fb6bd
|
|
| MD5 |
f9ff405b06a38ae862bf659808859f59
|
|
| BLAKE2b-256 |
ef8a1ce61014e96f01bfdba1074a6d094dd25ea06a613849b92a12ebd2b92847
|
File details
Details for the file fraiseql_confiture-0.3.6-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 565.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a577fe5bc6cd170330a9559c10c79faa7d81a4a4a0f2e82907c0e847f7b98199
|
|
| MD5 |
b95f7962aa5ac10cd033072783f73625
|
|
| BLAKE2b-256 |
2752e967f927fef50f0a28cb43ce3439623114d74588cbdf1c4142e96883cbb4
|
File details
Details for the file fraiseql_confiture-0.3.6-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: fraiseql_confiture-0.3.6-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 530.6 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7605f9a2b46687a2207694a64107088e36955a00172f2562034059c2f10ff768
|
|
| MD5 |
52003d2fa3abed6b902b0444d8a6a7c2
|
|
| BLAKE2b-256 |
baab3591a22e690ca517c9ee0bdd01defd6afc620ad4f40868d55d602b3c814d
|