v0.1.0

CASOONOpen Source

Your database design, as files you can trust.

Read your schema from PostgreSQL, MySQL, SQLite, SQL Server or MongoDB. Edit it visually or with an AI agent. Review every change in git, and ship it as a plan that only a human can approve.

cargo install --git https://github.com/casoon/databee databee
MIT OR Apache-2.0pre-1.0PostgreSQL first
Terminal: databee lint prints a warning verdict for the project shop (0 errors, 1 warning, 0 info), a Warnings group with one finding, PG002: the foreign key order_user_fk on order has no index starting with user_id, and the next step databee lint --fix. databee lint --fix then reports no findings and an Applied fixes group with the same finding marked fixed.
database families read into the model
5
languages of generated code
4
MCP tools in 6 profiles, read-only by default
28
MCP tools that can approve a plan
0

The problem

A schema is rarely in one place.

It lives in the running database, in a pile of migration files, in an ER diagram that went stale last spring, and in the heads of the people who built it. Changing it means hoping nobody has touched production, and an AI assistant that can reach your database is a risk you have to trust. databee makes one model the source of truth: a folder of JSON files that git can diff and a reviewer can read. Everything else is derived from it.

databee Studio

See your schema. Change it. Ship it with a plan.

Studio is the visual editor on top of the same project folder the command line uses. Open a project and the whole schema is on one canvas, with its findings beside it: entities with columns and keys, foreign keys routed around the boxes with crow’s foot markers, a position that is saved when you drag. Every edit is a changeset that is checked with a dry run before it is written.

databee Studio showing a sample orders project: five entities on a canvas with columns, primary and foreign keys, and foreign key lines with crow's foot markers. A side panel lists three warnings and two infos, two of them with an Apply fix button.
databee Studio on a sample orders project. The two foreign keys without an index are findings with an Apply fix button.

Studio · Editing

Edit in the diagram, not around it.

Select an entity and edit it in the side panel: columns, primary and unique keys, indexes, checks, enum types and namespaces. Drag from a column handle onto a column of another entity and you have a foreign key, with its ON DELETE and ON UPDATE choices. Deleting names the foreign keys of other entities that go with it, and Undo takes the last step back, also after a restart.

  • Findings at the entity, at the column and in a list, with Apply fix where one exists
  • A banner offers a reload when the project changed on disk; a conflicting edit is not retried
  • Keyboard: focus an entity or a foreign key, Enter opens it in the panel
The side panel of databee Studio with the entity order selected: name, comment, findings, columns with Edit and Drop, primary key, unique keys, indexes and foreign keys.

Studio · Preview

Read the SQL, then the plan, then approve.

A DDL view shows the PostgreSQL the model produces, with a copy button. An ALTER preview compares the model with a snapshot you named and lists every step with the lock it takes; destructive steps are flagged. Approving opens a dialog with the steps, the risks and the hash, and a destructive plan only goes through after you type its name.

  • Snapshots with a name, as the starting point of a plan
  • The approval is recorded for that exact hash and does not run anything
The ALTER preview dialog of databee Studio: a plan of two steps, one flagged destructive, with the lock each step takes and the plan hash, and a Review and approve button.
The Approve plan dialog of databee Studio: the risks (one destructive step, one ACCESS EXCLUSIVE lock), the two steps, the plan hash, and a field that asks for the plan name before a destructive plan can be approved.
Screenshots of the real interface, taken against Studio’s mock backend: the plan hash is a placeholder.

Studio · DDL

The SQL, before it exists anywhere.

The DDL view renders the whole model as PostgreSQL, from the same generator as databee generate ddl, so what you copy is what the command line writes.

The PostgreSQL DDL dialog of databee Studio: nine statements, starting with CREATE TYPE for the enum order_status and CREATE TABLE for audit_log, customer and order, with a Copy button.

Diagrams

An ER diagram that cannot go stale.

databee draws the diagram from the model files, so it is always the schema you have. The output is deterministic SVG or HTML: the same model gives the same bytes, so a diagram can be committed and reviewed. Light, dark and print themes, a focus view around one table, an overview for large schemas, and a diff view that marks what changed since a snapshot. Mermaid, Graphviz DOT and DBML are one command away.

Entity relationship diagram of the shop model, drawn by databee: a Catalog group with tags, product_tags and products, and a Sales group with customers, orders, order_items and customer_profiles, with primary keys, foreign keys, unique keys and crow's foot lines.
databee visualize render --format svg, run on the orders model of the test suite: entities grouped by namespace, keys and indexes marked, crow’s foot cardinalities.

01Lint and validation

Mistakes found before the database sees them.

Validation checks the project files and the model; lint applies PostgreSQL best practices such as a missing index behind a foreign key, a table without a primary key, timestamps without time zone or identifiers PostgreSQL would silently truncate. Safe fixes are one flag away, and an applied fix is an undo step.

  • Severities and suppressions (with a required reason) live in project.toml
  • Text, JSON and SARIF output for CI, and --fail-on for the exit code
  • Findings carry the file and JSON path of the value at fault
databee lint, then lint --fix
$ databee lint
⚠ Project `shop`: 0 errors, 2 warnings, 0 info

● Warnings (2)
  - [fix available] Foreign key `order_items_product_id_fkey` on `order_items` has no index starting with (product_id) ($.foreign_keys[1]) [PG002] at schema/shop/order_items.json
  - [fix available] Foreign key `product_tags_tag_id_fkey` on `product_tags` has no index starting with (tag_id) ($.foreign_keys[1]) [PG002] at schema/shop/product_tags.json

Next steps:
  • 2 findings can be fixed automatically
    $ databee lint --fix

$ databee lint --fix
✔ Project `shop`: no findings

● Applied fixes (2)
  - [fixed] Foreign key `order_items_product_id_fkey` on `order_items` has no index starting with (product_id) ($.foreign_keys[1]) [PG002] at schema/shop/order_items.json
  - [fixed] Foreign key `product_tags_tag_id_fkey` on `product_tags` has no index starting with (tag_id) ($.foreign_keys[1]) [PG002] at schema/shop/product_tags.json

02Changesets and undo

Every change reviewable, whole or not at all.

The model is one JSON file per table with stable IDs, so a pull request that touches one table touches one file, and a rename is a rename, not a drop and a create. A change is a changeset that is validated as a whole and written atomically, or it changes nothing. The last one can be taken back.

  • A stale revision is rejected, so a human, Studio and an agent cannot overwrite each other
  • --dry-run shows what would change without writing
  • Native properties of the source database are kept in the model
schema/shop/customers.json
{
  "$schema": "../../.databee/schemas/entity.schema.json",
  "id": "01M8SX996ARXDJTXX3E6BGG8CR",
  "namespace": "01M8SX9969G1FBQZP3THK3XSTZ",
  "name": "customers",
  "kind": "table",
  "fields": [
    {
      "id": "01M8SX996FXGGWZPTX9KEJWXRJ",
      "name": "id",
      "type": {
        "kind": "int",
        "bits": 64
      },
      "nullable": false,
      "extensions": {
        "postgres": {
          "version": 1,
          "data": {
            "identity": "by_default"
          }
        }
      }
    },
    {
      "id": "01M8SX996FSRG3KJSAB0V87NYS",
changeset.json
{"base_revision":"<revision>","ops":[
 {"op":"add_field","entity":"shop.orders","field":{"name":"shipped_at","type":{"kind":"timestamp","tz":true},"nullable":true}},
 {"op":"add_field","entity":"shop.orders","field":{"name":"currency","type":{"kind":"text"},"default":"'EUR'"}},
 {"op":"drop_field","field":"shop.products.price"}
]}
schema/shop/orders.json
@@ -65,6 +65,26 @@
         "scale": 2
       },
       "nullable": false
+    },
+    {
+      "id": "01M8WE6ACGR39E894KC32BE5ER",
+      "name": "shipped_at",
+      "type": {
+        "kind": "timestamp",
+        "tz": true
+      },
+      "nullable": true
+    },
+    {
+      "id": "01M8WE6ACG5F4BERH25BXFFBXH",
+      "name": "currency",
+      "type": {
+        "kind": "text"
+      },
+      "nullable": false,
+      "default": {
+        "source": "'EUR'"
+      }
     }
databee changeset apply, databee undo
$ databee changeset apply changeset.json
Applied 3 operations: 9 files changed, revision 401eddc8a15180b0bac73d961f5f9a1ea9d63a6bf8f4439ed025e5573154f011

$ databee undo
Undid changeset 1: 9 files restored, revision 961e5603db61cc9d720ff3dc5b05d5a85fc027e9e54678aba816c7151a2642c2

03Safe ALTER plans

Production changes with the risks written down.

databee compares two states of the model and writes an ALTER plan for PostgreSQL: lock-friendly steps, every step marked with the lock it takes, and destructive steps flagged. The plan has a hash. It runs only after a human approved that exact hash in a terminal; edit the plan and the approval is void. An interrupted run continues after its last completed step.

  • Approval has no --yes flag and is stored outside the project
  • Before it runs, the database is checked against the plan’s source model
  • Afterwards the database is compared with the target model
databee plan show ship-orders
$ databee plan show ship-orders
Plan `ship-orders`
hash:   e401b33ff3ceb7960836a4007e544f1b256e662a596c61bcfeaef737a603fe09
from:   snapshot:before
to:     current
status: not approved
steps:  3

  1. ALTER TABLE "shop"."products" DROP COLUMN "price"
     [lock: ACCESS EXCLUSIVE; DESTRUCTIVE]

  2. ALTER TABLE "shop"."orders" ADD COLUMN "shipped_at" timestamp with time zone
     [lock: ACCESS EXCLUSIVE]

  3. ALTER TABLE "shop"."orders" ADD COLUMN "currency" text DEFAULT 'EUR' NOT NULL
     [lock: ACCESS EXCLUSIVE]

⚠ Risks: 1 step destructive, 0 steps that rewrite a table

04AI agents over MCP

Let an agent design. Never let it decide.

databee mcp serve gives an AI client the same operations as the CLI, in profiles. The default profile only reads. Changing the model, generating, planning, running and exporting are separate profiles you switch on one by one, and tools outside them do not exist for the agent. No tool can approve a plan, no tool takes a URL or a password, and every reply that carries database text is marked as data.

  • Writes stay in known places: diagrams/, generated/, out/
  • An agent skill tells the assistant which tool answers which question
  • Works with any MCP client that starts a stdio server
reader
Look: summary, validation, diagrams, diff, the model with IDs. The default. 5 tools.
designer
Change the model through changesets, and undo. 5 tools.
generator
DDL, DBML and code. 3 tools.
planner
Snapshots, ALTER plans, transformation, fit, migration plans. 8 tools.
operator
Run a plan or migration that a human approved. 3 tools.
exporter
Export profiles and runs, within out/. 4 tools.
a real tool call
schema_apply_changeset  (profile: designer)
  dry_run: true
  base_revision: 961e5603db61…
  ops: add_field shop.orders.shipped_at timestamptz NULL
the reply: nothing was written
{
  "applied": false,
  "dry_run": true,
  "changed_files": [
    {"path":"schema/domains.json","change":"modified"},
    {"path":"schema/shop/orders.json","change":"modified"}
  ],
  "diagnostics": [
    {"rule_id":"PG002","severity":"warning","file":"schema/shop/order_items.json","fix_available":true},
    {"rule_id":"PG002","severity":"warning","file":"schema/shop/product_tags.json","fix_available":true}
  ]
}

Across databases

Move between systems, and be told what does not survive.

databee reads PostgreSQL, MySQL, MariaDB, SQLite, SQL Server and MongoDB into the same model and keeps their native properties. It converts a model to another dialect with every conversion marked, and migrates the data into PostgreSQL with a plan, an approval and a verification afterwards.

mysql to postgres: incomplete (open decisions)

35 exact, 47 equivalent, 15 lossy, 18 open decisions, 0 unsupported

four of its findings
warning DB-TRF-001: lossy shop.all_types.c_time: TIME becomes time
error DB-TRF-009: manual shop.customer.id: BIGINT UNSIGNED reaches 18446744073709551615, bigint stops at 9223372036854775807
error DB-TRF-008: manual shop.customer.is_active: TINYINT(1) is boolean only if the data has boolean meaning (values 0 and 1)
error DB-TRF-014: manual shop.customer.ft_customer_bio: FULLTEXT search has no direct counterpart (tsvector with a GIN index)

Where would this model fit best?

The analyze fit command scores the model for five systems with the reason of every deduction.

mysql
95 · excellent
postgres
83 · good
mssql
73 · workable
sqlite
67 · workable
mongodb
39 · poor

05Code generation

Models in your language, from the same source.

Rust with sqlx, TypeScript with Drizzle, Python with SQLAlchemy 2.0 and C# with EF Core, generated from the model and identical on every run. What a library cannot express, such as a check constraint or a partial index, is reported on the object instead of being silently dropped.

shop.rssqlx
pub struct Customers {
    pub id: i64,
    pub name: String,
    pub email: String,
    pub created_at: chrono::DateTime<chrono::Utc>,
}
schema.tsDrizzle
export const customers = shopSchema.table(
  "customers",
  {
    id: bigint("id", { mode: "number" }).generatedByDefaultAsIdentity().primaryKey(),
    name: text("name").notNull(),
    email: text("email").notNull(),
    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
  },
  (t) => [
    unique("customers_email_key").on(t.email),
  ],
);
models.pySQLAlchemy 2.0
class Customers(Base):
    __tablename__ = "customers"
    __table_args__ = (
        UniqueConstraint("email", name="customers_email_key"),
        {"schema": "shop"},
    )

    id: Mapped[int] = mapped_column(BigInteger, Identity(always=False), primary_key=True)
    name: Mapped[str] = mapped_column(Text)
    email: Mapped[str] = mapped_column(Text)
    created_at: Mapped[datetime.datetime] = mapped_column(DateTime(timezone=True), server_default=text("now()"))
Customers.csEF Core
public class Customers
{
    public long Id { get; set; }
    public string Name { get; set; } = null!;
    public string Email { get; set; } = null!;
    public DateTime CreatedAt { get; set; }
    public ICollection<CustomerProfiles> CustomerProfileses { get; set; } = new List<CustomerProfiles>();
    public ICollection<Orders> Orderses { get; set; } = new List<Orders>();
}

06Exports and test data

Realistic data without the real data.

An export profile writes rows and schema artifacts reproducibly, from one consistent read-only transaction. Take a subset that keeps every reference intact, mask personal columns with fake values that keep type and length, or skip the database entirely and generate synthetic rows from the model: foreign keys, unique keys, enums and simple checks hold, and the same seed gives the same bytes.

  • CSV, NDJSON and SQL inserts; the manifest lists a SHA-256 per file
  • Fields marked sensitive warn when exported without a mask, --strict stops
  • The masking secret is read from the environment and never written
exports/masked.toml
connection = "shop"

[[data]]
entities = ["shop.customers"]
format = "ndjson"

[data.mask]
email = { fake = "email" }
name = { fake = "name" }
databee export check masked
$ databee export check masked
Export profile `masked` is valid: 1 table, needs a connection
databee generate data --rows 3 --seed 1 --format csv
id,name,email,created_at
1,Elena Meyer,theo.neumann631@example.org,2020-05-27 12:32:25+00
2,Olga Unger,carla.gruber402@example.net,2018-10-14 19:21:15+00
3,Xenia Koch,olga.yilmaz453@example.org,2015-10-03 07:53:01+00

How it fits together

One model in the middle.

Databases, people and agents feed the model. Checks, diagrams, SQL, code and plans come out of it. The CLI, the MCP server and Studio are three doors to the same operations.

How databee worksA database is read into model files, or designed by hand, by Studio or by an AI agent through changesets that are applied all or nothing. The model is validated and linted, and from it databee generates DDL, code and diagrams, or an ALTER plan that a human approves for its exact hash before it runs against the database.How databee worksDatabase → Model files: pullYou, Studio, agent → Model files: changesetModel files → Validate, lintValidate, lint → DDL, code, diagrams: generateValidate, lint → ALTER plan: diff to snapshotALTER plan → Approved?Approved? → Run on database: approvedpullchangesetgeneratediff to snapshotapprovedDatabaseDatabaseYou, Studio, agentYou, Studio, agentModel filesModel filesValidate, lintValidate, lintDDL, code, diagramsDDL, code, diagramsALTER planALTER planApproved?Approved?Run on databaseRun on database
How databee worksA database is read into model files, or designed by hand, by Studio or by an AI agent through changesets that are applied all or nothing. The model is validated and linted, and from it databee generates DDL, code and diagrams, or an ALTER plan that a human approves for its exact hash before it runs against the database.How databee worksDatabase → Model files: pullYou, Studio, agent → Model files: changesetModel files → Validate, lintValidate, lint → DDL, code, diagrams: generateValidate, lint → ALTER plan: diff to snapshotALTER plan → Approved?Approved? → Run on database: approvedpullchangesetgeneratediff to snapshotapprovedDatabaseDatabaseYou, Studio, agentYou, Studio, agentModel filesModel filesValidate, lintValidate, lintDDL, code, diagramsDDL, code, diagramsALTER planALTER planApproved?Approved?Run on databaseRun on database
How databee worksA database is read into model files, or designed by hand, by Studio or by an AI agent through changesets that are applied all or nothing. The model is validated and linted, and from it databee generates DDL, code and diagrams, or an ALTER plan that a human approves for its exact hash before it runs against the database.How databee worksDatabase → Model files: pullYou, Studio, agent → Model files: changesetModel files → Validate, lintValidate, lint → DDL, code, diagrams: generateValidate, lint → ALTER plan: diff to snapshotALTER plan → Approved?Approved? → Run on database: approvedpullchangesetgeneratediff to snapshotapprovedDatabaseDatabaseYou, Studio, agentYou, Studio, agentModel filesModel filesValidate, lintValidate, lintDDL, code, diagramsDDL, code, diagramsALTER planALTER planApproved?Approved?Run on databaseRun on database
How databee worksA database is read into model files, or designed by hand, by Studio or by an AI agent through changesets that are applied all or nothing. The model is validated and linted, and from it databee generates DDL, code and diagrams, or an ALTER plan that a human approves for its exact hash before it runs against the database.How databee worksDatabase → Model files: pullYou, Studio, agent → Model files: changesetModel files → Validate, lintValidate, lint → DDL, code, diagrams: generateValidate, lint → ALTER plan: diff to snapshotALTER plan → Approved?Approved? → Run on database: approvedpullchangesetgeneratediff to snapshotapprovedDatabaseDatabaseYou, Studio, agentYou, Studio, agentModel filesModel filesValidate, lintValidate, lintDDL, code, diagramsDDL, code, diagramsALTER planALTER planApproved?Approved?Run on databaseRun on database

Who it is for

Backend teams
Keep the schema in the repository, review table changes like code, and get models in your language generated from it instead of written twice.
Database owners reviewing changes
Read an ALTER plan with its locks and destructive steps listed, and approve one exact hash, instead of reading a migration script and hoping.
Teams working with AI assistants
Let an agent propose schema changes through a read-only-by-default server, validate them, and show you the diff. It cannot approve or run anything you did not allow.
Consultants and migration projects
Take over an unfamiliar database as files, see what a move to PostgreSQL loses before you start, and migrate with a plan and a verification.

Before and with databee

Topicschema in the database and in migrationsWithoutschema as reviewable filesWith databee
Source of truthThe running database, plus migration files that may disagreeModel files in git, one per table, with stable IDs
DiagramA drawing somebody has to updateDrawn from the model by databee, same bytes every run
A schema changeA hand-written migration, reviewed as SQLA changeset, a diff of one file, an ALTER plan with risks
Running itWhoever has the credentialsOnly a plan a human approved, for that exact hash
AI assistantsAccess to the database, or copy and pasteA profile-based MCP server that cannot approve
Moving to PostgreSQLDiscover the differences in productionA conversion report: exact, equivalent, lossy, manual, unsupported

Source of truth

WithoutThe running database, plus migration files that may disagree

With databeeModel files in git, one per table, with stable IDs

Diagram

WithoutA drawing somebody has to update

With databeeDrawn from the model by databee, same bytes every run

A schema change

WithoutA hand-written migration, reviewed as SQL

With databeeA changeset, a diff of one file, an ALTER plan with risks

Running it

WithoutWhoever has the credentials

With databeeOnly a plan a human approved, for that exact hash

AI assistants

WithoutAccess to the database, or copy and paste

With databeeA profile-based MCP server that cannot approve

Moving to PostgreSQL

WithoutDiscover the differences in production

With databeeA conversion report: exact, equivalent, lossy, manual, unsupported

Status

Honest about where it stands.

databee is pre-1.0 and minor versions may break. PostgreSQL is the reference system. The other adapters support what their capability matrix says and a real server test confirms, no more.

  • ALTER plans and sql-copy exports exist for PostgreSQL only.
  • SQL Server is a source for transformation and migration, never a target.
  • MongoDB structure is inferred from a sample: an estimate, not a schema.
  • Studio is a macOS app bundle for now; other platforms are not verified.
  • Views, functions, triggers and partitioning are reported, not modelled.

Start where you are

Put your schema in git, where it belongs.

Start a project