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.5.tar.gz (917.5 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.5-cp314-cp314-win_amd64.whl (468.5 kB view details)

Uploaded CPython 3.14Windows x86-64

fraiseql_confiture-0.3.5-cp313-cp313-win_amd64.whl (468.5 kB view details)

Uploaded CPython 3.13Windows x86-64

fraiseql_confiture-0.3.5-cp313-cp313-macosx_11_0_arm64.whl (516.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fraiseql_confiture-0.3.5-cp312-cp312-win_amd64.whl (468.5 kB view details)

Uploaded CPython 3.12Windows x86-64

fraiseql_confiture-0.3.5-cp312-cp312-manylinux_2_34_x86_64.whl (550.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fraiseql_confiture-0.3.5-cp312-cp312-macosx_11_0_arm64.whl (516.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fraiseql_confiture-0.3.5-cp311-cp311-win_amd64.whl (468.4 kB view details)

Uploaded CPython 3.11Windows x86-64

fraiseql_confiture-0.3.5-cp311-cp311-manylinux_2_34_x86_64.whl (552.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

fraiseql_confiture-0.3.5-cp311-cp311-macosx_11_0_arm64.whl (517.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5.tar.gz
  • Upload date:
  • Size: 917.5 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.5.tar.gz
Algorithm Hash digest
SHA256 c345dd7e5ba17504767d4d054a5d8d1c49cac817182913a5730e55d7ce49468f
MD5 83b023ea913f8242b85ea0a7a4dcea6d
BLAKE2b-256 580b8a6d95fbb9587d9bdffc960875b73cd2203c0a388bb2137daf49118aae4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 468.5 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.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1738acba7227008e2b626e2ecede8f79a421d74a6af0712906efcad8e2184452
MD5 de7322a9514c226bcbe30c95624899e5
BLAKE2b-256 41bb724c43f22082b709a59d104ec3db13086f32b2b66a736818d996429a2fca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 468.5 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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b5a639340abab2cfe9cb443cb68bcf48488b54011986e4444c43ac13dd2be8bb
MD5 3e195e7e186b8c48d232cdad74212738
BLAKE2b-256 65a1703dca7dbb5c91d4bc996abe7d5d1b27cbb14098e1a9467cf844cd88da72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 516.9 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.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4a4bf812a4a037e430aa7c181c72b08fbdd8120fb7fe0a108caa9e5a2ce9f64
MD5 bb20dcf1190eae2368b525e995cfc321
BLAKE2b-256 2ee97b33d138962ff1bcc13bd9d661ea27987beddf0561d06f0181342326ea90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 468.5 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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8b6f8e26cd08197cdf583422a9fd9d03d6621bfa4171cf030faed4c6f1f2efbc
MD5 a64c60047f9f3785b6882246f8dc649e
BLAKE2b-256 855eadc2c1b28eb038d6e54146b94f830d2af56c420051ec8f23c00b8add3147

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 550.7 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.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 02fcc1af31897d1113815d0f7ddcee69e7afec68e3c64b4f360feecd062ead3f
MD5 44bba95b7f1b805adefdae15115f08e0
BLAKE2b-256 7fa4b8eb94a5d5c477e3bcad3620058672be4f5c6afcb8d4d9baac119bdc0a41

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 516.9 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.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4dedc5c14b867a239dbd2624e88f9f5e5ce0e4d95547d011ee2fc2d6150c25cb
MD5 e8c1fd0d757a514c5d91edaf926487ea
BLAKE2b-256 c2d933317df98e74deb7afbeca9f7804905a15a7953ef3c4e236834ed6bad688

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 468.4 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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 27715902189410d4db7edf03d80c3dc3e1e8c1768d88dc5ed78d610c776cc0cc
MD5 97b853d7f2e9d070632f95807f3310ee
BLAKE2b-256 9550567bac69224b95d03666d5b294f8b4370b7631cef18113398a6e3c9a4477

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp311-cp311-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 552.2 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.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9957c5bcbe4ff9375da6bccc2a4897eb0f3a316d99a14114ddcfb5435bb4b25f
MD5 02afb31cdaf24dac636f3eeab18a0726
BLAKE2b-256 09a39ce560678b27b070548bc5249b97f775fbdfc36d4db4cfe10601b0c369e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fraiseql_confiture-0.3.5-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 517.1 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.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23b9ec2175120e50ab9ad9d20441020ddf799ae6444955edbda02739943b3671
MD5 edeb5daca0d4ed86fea73a085b13d442
BLAKE2b-256 475fd0c51fd53318dcfd16473136b2c68f6b8e964420df96769512ac18ae9aec

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