Version control for database config: the options compared

Your app reads config from the database: feature flags, prompts, model routing, pricing, policy rules. People, admin consoles, scripts and now coding agents edit those rows while the app runs. When something breaks, you want to know what changed, who changed it, what it was before, and how to put it back.

There are six common ways to get some or all of that. This page compares them for config records in MongoDB or Postgres, including where cfgit, which I build, does not fit.

The short answer

Pick by where the config lives and how it changes:

  • Config can live in files and only changes on deploy: keep it in Git.
  • It is mostly on/off flags and targeting rules: a feature-flag service.
  • You are changing the schema: a migration tool.
  • You want every table versioned and can switch databases: Dolt.
  • You only need a compliance record of who ran what: the database audit log.
  • Config rows stay in your MongoDB or Postgres and get edited live: a history layer next to them, either one you build with triggers or change streams, or cfgit.

Side by side

ApproachConfig stays where it isBefore and after diffOne-step rollbackFlags edits made outside itReview before a write
Database audit logYesNo, it logs the operationNoLogs every operationNo
Triggers or change streamsYesIf you store both versionsYou build itCaptures every writeYou build it
Dolt or DoltgresNo, you move to DoltYes, per cellYesYes, as uncommitted changesBranches and merges
Migration toolsYesSchema yes, rows only via scriptsDown scriptsSchema drift onlyCode review of scripts
Config files in GitNo, it moves to filesYesRevert and redeployNothing to edit outside itPull requests
Feature-flag serviceNo, it lives in their serviceIn their change historyUsuallyNot applicableApprovals, on some plans
cfgitYesYes, per fieldYes, to any version, tag or timeYes, and refuses to overwriteDry runs, impact, branches and PRs

Database audit logs

MongoDB can write an audit log of operations in MongoDB Enterprise and on Atlas clusters M10 and larger. Postgres has the pgaudit extension, which logs statements to the server log.

An audit log answers who ran which command and when. It does not keep the document as it was before the change, so it cannot show a diff or put a record back, and reading it means searching log output. It is the right tool for compliance and security review, and a poor one for "the planner config changed at 3am, what was it before".

Pick it for: a who-did-what record that auditors ask for.

Triggers or change streams into a history table

The do-it-yourself route. In Postgres, a trigger copies the old row into a history table on every update; the temporal_tables extension packages that pattern. In MongoDB, a small service listens to a change stream (which needs a replica set) and writes each change somewhere.

It catches every write, whoever made it, which is its real strength. Everything else is yours to build and keep running: storing both versions, retention, a way to read the history, restore, and any review step before a change goes live.

Pick it for: one or two tables, a team that is happy to own the code, and no need for review before writes.

Dolt and Doltgres

Dolt is a SQL database with Git built in: commits, branches, merges and diffs on every table. Dolt speaks the MySQL protocol, and Doltgres is the Postgres-compatible version.

It is the most complete answer if version control should cover all of your data. The cost is that it is a database: you run it instead of the one you have, and your config moves into it. It does not cover MongoDB.

Pick it for: data where versioning is the product, or a new system that can start on Dolt.

Schema migration tools

Flyway, Liquibase and Atlas version the shape of the database as ordered scripts that run through CI. Atlas can also detect when a live schema drifts from what the migrations describe.

They are built for schema, not for config rows that change through an admin page. You can ship a row change as a migration, but every edit then needs a script and a deploy, and an edit made straight in the database is invisible to them.

Pick it for: tables, columns and indexes. Use it alongside a tool for row-level config.

Config files in Git

Keep config as YAML or JSON in the repository and ship it with a deploy. You get Git exactly: history, diffs, review and revert.

It stops working when config has to change without a deploy, when a non-engineer edits it in an admin console, or when it already lives in the database because the app reads it there. Then Git holds a copy, and the database holds the truth.

Pick it for: config that only engineers change, on deploy.

Feature-flag and remote-config services

LaunchDarkly, Unleash, Flagsmith and ConfigCat store flags and remote config for you, with change history, targeting, gradual rollouts and, on some plans, approvals.

They are excellent for flags. They are not a way to version documents your app already keeps in its own database, such as agent configs, prompts or pricing rules. Moving those into a flag service means a new dependency in the request path and a second source of truth.

Pick it for: on/off flags, experiments and rollouts.

cfgit

cfgit is an open-source CLI and MCP server that adds Git-style version control to config records in the MongoDB or Postgres you already run. The records stay where they are; history lives in collections or tables next to them.

Where it does not fit, by design: user content, events, logs and high-write tables; it stores full versions of each record. On MongoDB it needs a replica set for transactional writes. On Postgres it expects each table to hold the record in a doc jsonb column. It notices direct database edits rather than blocking them.

$ pip install 'cfgit[mongo]'
$ cfg import --all -m "initial import"
$ cfg status
agent_configs:planner changed_outside_cfgit

Try it without a database: uvx --python 3.12 --from 'cfgit[demo]' cfg demo. The MongoDB and Postgres how-tos walk through a real setup, and detecting config drift covers the drift workflow.

Using them together

These are not exclusive. A common setup: migrations for the schema, a flag service for on/off flags, the audit log for compliance, and cfgit for the config documents people and agents edit while the app runs.

Questions

Can't I just use MongoDB's audit log?

It tells you who ran an operation, not what the document looked like before and after, and it has no restore. It is also only in MongoDB Enterprise and Atlas M10 and larger clusters. It is a good companion to versioning, not a replacement.

Do I have to move my config to use cfgit?

No. The records stay in the same MongoDB collection or Postgres table and your app keeps reading them the same way. cfgit keeps history in separate collections or tables next to them.

Is cfgit a replacement for Dolt?

No. Dolt is a database you run instead of MySQL or Postgres, with version control built into every table. cfgit adds version control to a few config collections or tables in the database you already have, including MongoDB, which Dolt does not support.

How is this different from schema migrations?

Migration tools such as Flyway, Liquibase and Atlas version the shape of the database as scripts that run in order. cfgit versions the contents of individual config records that people and agents edit while the app runs.

Does cfgit stop people editing the database directly?

No, and it does not need write access to be the only path. It notices the edit: cfg status flags the record, cfg diff shows the change, and you adopt it as a new version or restore what was recorded. Until then cfgit refuses to write over it.