Skip to content

v0.0.9

Choose a tag to compare

@thephw thephw released this 22 Oct 21:01
· 10 commits to main since this release
dd1f07c

What's changed

New: PostgreSQL adapter

  • PostgresAdapter stores feature flags in your own PostgreSQL database. Install it with pip install "feature_gate[postgres]" (psycopg 3). psycopg is only imported when you use this adapter, so MemoryAdapter and PosthogAdapter work without it.
    • Configure it with PostgresAdapter(database_url=...), or FEATURE_GATE_DATABASE_URL, falling back to DATABASE_URL. You can also pass an existing psycopg connection; if it's already inside a transaction, the adapter's writes become part of it.
    • Behaves like MemoryAdapter: adding a flag that already exists is harmless, a missing key raises FeatureNotFound, and features() returns flags in the order they were added.
  • feature-gate-migrate command creates and updates the adapter's tables on your database. Running it again only applies new migrations, and a PostgreSQL advisory lock stops two deploys from migrating at the same time. You can also call it from Python as feature_gate.migrate.migrate(connection).
  • Configurable table prefix, defaulting to feature_gate_. Set it with table_prefix=, --table-prefix or FEATURE_GATE_TABLE_PREFIX. The migrations and the adapter must use the same prefix.
  • Feature IDs are UUIDv7s, created by a <prefix>uuidv7() function the migration adds, so PostgreSQL 13 and later are supported. The full schema is in the README.

Compatibility

  • PostgreSQL 13+ for the new adapter. CI tests it on PostgreSQL 16 and 18.
  • Python support is unchanged (3.10+). CI runs the suite on 3.10 and 3.15.

Development & packaging

  • New CI workflow runs the test suite on every pull request, on Python 3.10 and 3.15 against PostgreSQL 16 and 18.
  • The publish workflow now runs the PostgreSQL tests against a postgres:16 service before publishing.
  • PostgreSQL tests run locally when FEATURE_GATE_TEST_DATABASE_URL is set; otherwise they're skipped.

Full changelog: v0.0.8...v0.0.9