Skip to content

schema-engine

Choose a tag to compare

@albrtaraya albrtaraya released this 24 Jul 01:24
· 18 commits to main since this release
f7a81b1

schema-engine v2.1.0

The schema engine powers Dbcube's declarative schema workflow: it reads your
.cube files and turns them into real database structure across MySQL,
PostgreSQL, SQLite and MongoDB.

What's new in v2.1.0

Vector columns are now part of the schema language. A table stops being
either relational or vectorial — it can be both, and the engine materializes it.

  • New column types vector and blob. A vector column declares its
    dimension, and optionally a metric, an index method and the columns that feed
    it:

    embedding: {
      type: "vector";
      dimension: 1536;                 // required — the per-column lock
      metric: "cosine";                // cosine | euclidean | dotProduct
      index: "hnsw";                   // hnsw | ivfflat | none
      from: ["name", "description"];   // auto-embed source columns
      model: "text-embedding-3-small";
      sync: "auto";
    };
  • What it generates on PostgreSQL — CREATE EXTENSION IF NOT EXISTS vector
    before the table, the column as vector(<dimension>), and an ANN index after
    it with the opclass derived from the metric (cosine → vector_cosine_ops,
    euclidean → vector_l2_ops, dotProduct → vector_ip_ops). Both table:fresh
    and table:refresh emit them.

  • dbcube_vectors_config — the engine persists one row per vector column
    (dimension, metric, index type, from, model, sync) into the local config
    database. This is the contract the ORM reads to auto-embed on insert/update
    and to search the column; without it the declarative half would not exist.

  • Vectors are PostgreSQL-only, and say so. On another engine, or with the
    dimension missing, table:fresh fails with an explicit error instead of
    producing a table that would break at the first query.

Everything is additive: a .cube without vector columns parses and behaves
exactly as before.

Fixed

  • Boolean defaultValue no longer breaks PostgreSQL. A column declared
    { type: "boolean"; defaultValue: "false" } generated DEFAULT 0, which
    PostgreSQL rejects outright ("column is of type boolean but default
    expression is of type integer") because it has a real BOOLEAN type and no
    implicit cast from integer. It now emits DEFAULT TRUE / DEFAULT FALSE on
    PostgreSQL and keeps 1 / 0 on MySQL and SQLite, which have no boolean type
    of their own.
  • description is optional in @meta again. @meta({ name: "users"; });
    did not match the parser, so the table name came out empty and the engine
    emitted CREATE TABLE (...) — a syntax error that named no table. A missing
    name is now a clear error at parse time instead of invalid SQL at execution
    time, and the properties may appear in any order.

Also included (from the unreleased v1.1.2 line)

  • config.db is created whenever the engine runs. Applying a trigger in a
    project with no prior migration used to fail with unable to open database file (SQLite code 14), because .dbcube/config.db was only created by table
    operations. The config's SQLite connector now uses create_if_missing.
  • PostgreSQL seeder, autoincrement and fresh drop-order fixes.

What's new in v1.1.1

  • Cloud databases over TLS — connect to managed providers (Supabase, Neon,
    RDS, PlanetScale, Aiven, MongoDB Atlas) with a single URL connection string;
    TLS is negotiated automatically.
  • Managed databases skip CREATE DATABASE — when a URL is provided the
    database already exists at the provider, so the engine no longer attempts to
    create it (fixes a "zero-length delimited identifier" error on cloud setups).

What it does

  • .cube schema files — parses .table.cube, .alter.cube, .seeder.cube
    and .trigger.cube definitions.
  • Migrations — table:fresh, table:refresh and table:alter create and
    evolve tables, ordering them so foreign-key targets come first.
  • Safe ALTERs with rollback — .alter.cube applies only pending changes;
    migrate:rollback reverts them.
  • Seeders & triggers — loads seed datasets and registers runtime triggers.
  • Introspection — dbcube run pull generates .cube files from an existing
    database.

Binaries available

Latest

Platform Download
Windows x64 schema-engine-v2.1.0-windows-x64.zip
Linux x64 schema-engine-v2.1.0-linux-x64.zip
macOS x64 (Intel) schema-engine-v2.1.0-macos-x64.zip
macOS arm64 (Apple Silicon) schema-engine-v2.1.0-macos-arm64.zip

Install / update

The correct binary for your platform is fetched automatically, or explicitly:

dbcube run download schema-engine          # latest
dbcube run download schema-engine v2.1.0   # a specific version

Compatibility

  • Node.js 18+ · Windows x64, Linux x64, macOS x64 & arm64.
  • Works with MySQL, PostgreSQL, SQLite and MongoDB — local or cloud (TLS).
  • Vector columns require PostgreSQL with the pgvector extension available.

Checksums (SHA-256)

d620293ea060db46dd7c048285713bdb2b68e8cac11281479bffcfb4000c5b8e  schema-engine-v2.1.0-windows-x64.zip
4b9bb7ceceaef4a3c7fd8162dad6532789172877b4c25e5acb9c032ba288b040  schema-engine-v2.1.0-linux-x64.zip
79ef98a21629446ab75238e60fbcda1cd8dacf931e473b9e73bdc47a51e34cd9  schema-engine-v2.1.0-macos-x64.zip
515737b779775e61afb5a8b1b1c7b354757d20e535d4aaa24f884d642fd77ae1  schema-engine-v2.1.0-macos-arm64.zip