v0.1.0

Model files and stable IDs

How a databee project is laid out on disk, why every object has an ID, and what is kept from the database.

A project is a folder of text files meant to live in git.

shop/
├── project.toml             name, dialect, lint configuration, extensions
├── schema/
│   ├── namespaces.json
│   ├── types.json           enum and other named types
│   ├── domains.json         business domains, when the project has any
│   └── shop/
│       ├── customer.json    one file per table or collection
│       └── order.json
├── snapshots/<name>/        immutable copies of the model
├── plans/                   ALTER plans (.json and .sql)
├── exports/                 export profiles (.toml)
├── mappings/                transformation decisions (.toml)
├── migrations/              migration plans
├── diagrams/                rendered diagrams and layout.json
├── generated/               generated code
├── .databee/                undo history and JSON Schemas
└── out/                     export and transformation output

Only project.toml and schema/ are required; the other folders appear when you use the feature. .databee/ and out/ are in the .gitignore that databee init writes: the undo history is local, and out/ can hold personal data.

One file per entity

Each entity file names its fields, keys, foreign keys, indexes and checks, and begins with a $schema reference to a JSON Schema in .databee/schemas/, so editors and agents can validate and complete it. Because each table is its own file, a pull request that touches one table touches one file.

Stable IDs

Every object, including every field, key and index, has an ID. References between objects use IDs, not names. That is what lets a rename survive:

  • A rename is a change of the name of an object that keeps its id, so a diff, a snapshot comparison or an ALTER plan sees a rename instead of a drop and a create.
  • databee pull matches objects to the earlier model by their catalog identity in PostgreSQL, so a table renamed in the database keeps its ID on the next pull. MySQL and SQLite have no stable catalog identity; their objects are matched by name.
  • Changesets address objects by qualified name (shop.order, shop.order.customer_id) or by ID.

Keep the IDs if you edit files by hand.

Native properties are kept

The model has logical types (int with bits, decimal with precision and scale, timestamp with tz, text, uuid, …) and, next to them, the native properties of the system the object came from: UNSIGNED, AUTO_INCREMENT, ENUM and SET values in MySQL, affinity and STRICT in SQLite, clustering and INCLUDE columns in SQL Server, validators and sample statistics in MongoDB. They sit in versioned extensions (extensions.mysql, extensions.sqlite, extensions.mssql, extensions.mongodb) and are preserved when you edit around them.

What a conversion cannot carry is reported at the object it concerns, not dropped silently. See the capability matrix.

Documents and inferred structure

A MongoDB project has collections instead of tables. Their fields come from the $jsonSchema validator (origin: declared) and from a sample of documents (origin: inferred, with a confidence). A field is optional if a document may lack it, which is not the same as nullable (an explicit null). A reference found because ObjectId values match the _id of another collection is marked inferred and is never a constraint anywhere: DDL, plans, code and lint leave it out, and diagrams draw it dashed.

Edit this page on GitHub · Docs for v0.1.0