Skip to main content

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.

License: MIT Python 3.11+ PostgreSQL 12+ CI Code style: ruff Made with Rust Part of FraiseQL Status: Beta


๐Ÿ“ 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:

  1. Read all .sql files in db/schema/
  2. Execute them once (in order)
  3. 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:

Advanced:

API Reference

Examples


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:

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:

  • FraiseQL - Modern GraphQL framework for Python
  • Confiture - PostgreSQL migration tool (you are here)

Making jam from strawberries, one migration at a time. ๐Ÿ“โ†’๐Ÿฏ

Vibe-engineered with โค๏ธ by Lionel Hamayon

Documentation โ€ข GitHub โ€ข PyPI

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

fraiseql_confiture-0.3.7.tar.gz (932.4 kB view details)

Uploaded Source

Built Distributions

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

fraiseql_confiture-0.3.7-cp314-cp314-win_amd64.whl (482.8 kB view details)

Uploaded CPython 3.14Windows x86-64

fraiseql_confiture-0.3.7-cp313-cp313-win_amd64.whl (482.8 kB view details)

Uploaded CPython 3.13Windows x86-64

fraiseql_confiture-0.3.7-cp313-cp313-macosx_11_0_arm64.whl (531.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fraiseql_confiture-0.3.7-cp312-cp312-win_amd64.whl (482.9 kB view details)

Uploaded CPython 3.12Windows x86-64

fraiseql_confiture-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl (564.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fraiseql_confiture-0.3.7-cp312-cp312-macosx_11_0_arm64.whl (531.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fraiseql_confiture-0.3.7-cp311-cp311-win_amd64.whl (482.7 kB view details)

Uploaded CPython 3.11Windows x86-64

fraiseql_confiture-0.3.7-cp311-cp311-manylinux_2_34_x86_64.whl (566.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

fraiseql_confiture-0.3.7-cp311-cp311-macosx_11_0_arm64.whl (531.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file fraiseql_confiture-0.3.7.tar.gz.

File metadata

  • Download URL: fraiseql_confiture-0.3.7.tar.gz
  • Upload date:
  • Size: 932.4 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

Hashes for fraiseql_confiture-0.3.7.tar.gz
Algorithm Hash digest
SHA256 433e2a4f241980504440d30596d80cbc00bcf0bc49b2950988547c17db2110d8
MD5 cb9b07214b9e26d77655612f72d05e65
BLAKE2b-256 f50253212b005be335ddf8e4ccc9ffd4bc7876d5a5d035b87a56cab928747648

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 482.8 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

Hashes for fraiseql_confiture-0.3.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 93349e86b3c83b5dcfd80c4dab9b789d6dd02e601a78a9e8ab924a31aac2ed19
MD5 bfffecd9163a4755b23c8e21756aaca6
BLAKE2b-256 ecd7c3e1e6d3a07e529c5a9444ff4f3b3d3fb52409f5492fad6ac0ddc976cbab

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 482.8 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

Hashes for fraiseql_confiture-0.3.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fe13c21a725835b15395b72d0e8b422692a9dd2e9c71f27420e1d4f3af39602a
MD5 e5ee2e547331116e9825e371ca686077
BLAKE2b-256 0554d7d10a6a24e3c8a137c1ca757e0046897ca5009d68f5f03b00d2f994275f

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 531.1 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

Hashes for fraiseql_confiture-0.3.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d925a5bce18a5c1c837651aee5e60f2c72e6c28e6a552d9f916a48a34b2209b7
MD5 474e6a16ad583cb965467b63c0dadc00
BLAKE2b-256 89312da9257198e2eb235d897806d18029058406dca6cef2a69a867d3f144987

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 482.9 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

Hashes for fraiseql_confiture-0.3.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 43c792f84ee3d05bde5718be1e64f5c5e55a8fc8781a5ad2863072866476fa26
MD5 2751410afc2dfa0586f77c08b36140f1
BLAKE2b-256 cedb6b1da51efc984d2076e8b9f3443679e891c9f172c4bc7af23cbf4022a25a

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 564.9 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

Hashes for fraiseql_confiture-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 761f136dba775a2c8ef0e89b0a304d42920d9545c7284efd1f1efc6ca48d9a14
MD5 b07e522a8c75a7a6863c44c468244ee3
BLAKE2b-256 500a1519eb91dda7a74e997a5c74027c7c185fc029a555fa64fb746ef051dfda

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 531.1 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

Hashes for fraiseql_confiture-0.3.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a1d31988b197130259bb51b226b45742a9acdb526e935d0bd5024e4ecd15de9f
MD5 c4025afeee5b38c14a94d830d532cf95
BLAKE2b-256 8b77b3ed7698e79fe70d35395897ec6b660fc4e5533569edd35fbb6932f7d645

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 482.7 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

Hashes for fraiseql_confiture-0.3.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6909902da4b19db814ccd4c81bcb06e26e5a8764621ff07b21673f36f1aa7db9
MD5 0a8a4965304d71a3f8e4825b6197de01
BLAKE2b-256 55c80e397e822f38cbf798ad77de9cd868a45c4060a1f4deebf3db1baaeff784

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp311-cp311-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 566.4 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

Hashes for fraiseql_confiture-0.3.7-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 60b6c0779a1ea980551700b44976c8ead3e375243891fe962d8d819777a6928c
MD5 38736e4060031c76c69b16563d1df42b
BLAKE2b-256 e3c7a6df6bbef972e9a64faee030b739289ab5b95dc54d0845d7c0c208d157bf

See more details on using hashes here.

File details

Details for the file fraiseql_confiture-0.3.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fraiseql_confiture-0.3.7-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 531.3 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

Hashes for fraiseql_confiture-0.3.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bf46a7132389024c33c85b8297d68b3692c9654cad7a30c54430a7a615e9c944
MD5 e511b0181d2bbc03dabf78206f65da52
BLAKE2b-256 b56495f21d6c72717887ddd6a0e3140eaaf91acf3a87dd75226f47a015f906fc

See more details on using hashes here.

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