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.6.tar.gz (930.2 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.6-cp314-cp314-win_amd64.whl (482.2 kB view details)

Uploaded CPython 3.14Windows x86-64

fraiseql_confiture-0.3.6-cp313-cp313-win_amd64.whl (482.2 kB view details)

Uploaded CPython 3.13Windows x86-64

fraiseql_confiture-0.3.6-cp313-cp313-macosx_11_0_arm64.whl (530.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fraiseql_confiture-0.3.6-cp312-cp312-win_amd64.whl (482.2 kB view details)

Uploaded CPython 3.12Windows x86-64

fraiseql_confiture-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl (564.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fraiseql_confiture-0.3.6-cp312-cp312-macosx_11_0_arm64.whl (530.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fraiseql_confiture-0.3.6-cp311-cp311-win_amd64.whl (482.0 kB view details)

Uploaded CPython 3.11Windows x86-64

fraiseql_confiture-0.3.6-cp311-cp311-manylinux_2_34_x86_64.whl (565.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

fraiseql_confiture-0.3.6-cp311-cp311-macosx_11_0_arm64.whl (530.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Hashes for fraiseql_confiture-0.3.6.tar.gz
Algorithm Hash digest
SHA256 0692454a143006d9c196ffa49387292f4c3ba213735d6e70827adefc1898a80a
MD5 7119b7c14cf38aa8601113300f5a6b15
BLAKE2b-256 c17e6ab7df1b7431c4f7bad59f725043f71c107b0d2c0d2f9c8aff3423608cb1

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 36c57c0f934a24537f478e6027ff7e4e8ad4ee8cfd50703824e45398104c28d4
MD5 f4e4feda6b7e58b0a837a695e0cc8911
BLAKE2b-256 bf30e1a5f0d7b59eaa3456ebd3150b3e8f1176f75f92d01e1143c2ede66cf761

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ad884008a06e7365f26888227e8b9b9e2a7a5349bfb6d4e8a3ddd7649229a2f2
MD5 2323143deb56cdccb746fd11b194dfe6
BLAKE2b-256 dd778843b010da833512da8acc9b804943fe78c2d03d274c27584e2ce50f07ec

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03d7ee03d8f0fc1ca92d81aa832282ae387dbaba772ca7908eca1875f2ff1746
MD5 333851b6a70d1853d60515165852e579
BLAKE2b-256 79102c827a180b9849c0dea90dfbb201d7acd22a8a3bd5aa03e72c9d6a8513df

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 35647ec9bafedad71d2741af874b9673cc0fbbbef1d6d22da395e495e5224d0d
MD5 d0a9bc37d3981928a7cc8aefa89efc3f
BLAKE2b-256 3c78ba94b7736b671cc91f9c0f6477bf8ae0b628b5cc0e01e51e78f43aa1906b

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e1e8e9829e9ce1931e4ce39c1382210ffbe87fa59dd924ef0d21c764220b9094
MD5 a17e30d4f69987a85f1b53e346cef5fb
BLAKE2b-256 c40e9cb28880c9bdacf630228b703ba4364c9770485ff25daa0139dac11943ef

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b3a010eaaa6bdd89ac66a0748856f61f0b30e3d5ce5b0f2376da5c2b5203f3d
MD5 f787c787e0eeee01a794dc9a02bcd028
BLAKE2b-256 2f0bb2589b7e3778eab9e2bc0b8079b5750063ce54ea4c90c33d8ceb67e17380

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3ad993a352f6abe05d5aeec7d3c0ba7a578b566d1a2f21473f03c58f3a2fb6bd
MD5 f9ff405b06a38ae862bf659808859f59
BLAKE2b-256 ef8a1ce61014e96f01bfdba1074a6d094dd25ea06a613849b92a12ebd2b92847

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a577fe5bc6cd170330a9559c10c79faa7d81a4a4a0f2e82907c0e847f7b98199
MD5 b95f7962aa5ac10cd033072783f73625
BLAKE2b-256 2752e967f927fef50f0a28cb43ce3439623114d74588cbdf1c4142e96883cbb4

See more details on using hashes here.

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

Hashes for fraiseql_confiture-0.3.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7605f9a2b46687a2207694a64107088e36955a00172f2562034059c2f10ff768
MD5 52003d2fa3abed6b902b0444d8a6a7c2
BLAKE2b-256 baab3591a22e690ca517c9ee0bdd01defd6afc620ad4f40868d55d602b3c814d

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