v0.1.0

Changesets and undo

Why every change to the model is a changeset, what the operations are, and how undo works.

A changeset is a JSON document: the revision of the model it was written against, a list of operations, and optionally "dry_run": true.

{
  "base_revision": "cde658a2…",
  "ops": [
    { "op": "add_field", "entity": "shop.order",
      "field": { "name": "placed_at", "type": { "kind": "timestamp", "tz": true }, "default": "now()" } }
  ]
}

Whole or not at all

databee checks the changeset as a whole against the current model, validates the result, and writes the files atomically. If anything is wrong, every file stays as it was and all diagnostics come back in one reply, so a fix does not take several round trips. --dry-run (or dry_run) runs everything except the write.

The revision is a hash of the model. If the model changed since the changeset was written, the changeset is rejected with DB-CHG-001; read the model again with databee revision (or schema_get over MCP) and rebuild it. This is what keeps a human, Studio and an agent from overwriting each other’s work.

Code Reason
DB-CHG-001 the model changed since the base revision
DB-CHG-002 a reference (name, ID or @label) does not resolve
DB-CHG-003 undo is not possible
DB-CHG-004 an operation is invalid

Operations

add_namespace, add_entity, rename_entity, drop_entity, add_field, alter_field, rename_field, drop_field, set_primary_key, add_unique, drop_unique, add_foreign_key, drop_foreign_key, add_index, drop_index, add_check, drop_check, set_comment, add_enum, alter_enum_values.

Operations that create something can set "ref": "customer"; later operations write "@customer". The reply maps each label to the new ID. databee changeset schema prints the complete JSON Schema. Renames keep the ID.

Undo

Every applied changeset leaves an entry in .databee/history/, and so does a --fix from validate or lint. databee undo takes the last one back, and again takes the one before it. It refuses, with DB-CHG-003, if the files changed since, so it never overwrites an edit made by hand or elsewhere. databee undo --dry-run says whether undo is possible and which changeset it would take back.

The history is local to a working copy (it is in the .gitignore); it is a safety net for the session, not a replacement for git.

One path for every client

The CLI, the MCP tools schema_apply_changeset, schema_add_entity, schema_add_field and schema_add_foreign_key, and every edit in Studio build a changeset and send it through this path. They get the same validation and the same undo.

Edit this page on GitHub · Docs for v0.1.0