What Database Technologies Are Used in OpenWork? MySQL and SQLite Explained

OpenWork uses MySQL (with PlanetScale compatibility) for core enterprise data and SQLite for local runtime state, both accessed through the type-safe Drizzle ORM.

If you are exploring the different-ai/openwork repository, understanding the database technologies used in OpenWork is essential to grasping its hybrid persistence architecture. The platform splits data storage between a robust relational engine for enterprise records and a lightweight file-based store for local workspace configuration. Both layers are managed through the modern, type-safe Drizzle ORM.

Core Enterprise Data Layer: MySQL

MySQL serves as the main relational database for OpenWork's enterprise backend, powering organizations, users, policies, and plugins. The @openwork-ee/den-db package centralizes this layer, defining schemas with mysqlTable and mysqlEnum and connecting via Drizzle ORM.

MySQL Schema Definitions

In ee/packages/den-db/src/schema/*.ts, the enterprise backend declares tables using Drizzle ORM's mysql-core primitives. These schema files export type-safe table definitions that enforce relational constraints across the Den services.

MySQL Client and Connection Drivers

The ee/packages/den-db/src/client.ts module creates the Drizzle client. It supports two driver configurations:

  • drizzle-orm/mysql2 for standard MySQL connections.
  • drizzle-orm/planetscale-serverless for PlanetScale-compatible serverless deployments.
import { drizzle } from "drizzle-orm/mysql2";
import { mysqlTable, varchar } from "drizzle-orm/mysql-core";

// Create a typed DB client
const db = drizzle(mysqlConnection, { schema: {/* generated from schema files */} });

(source: ee/packages/den-db/src/client.ts)

Local Runtime State: SQLite

SQLite provides fast, file-based persistence for workspace-specific configuration, temporary caches, and per-session data. This avoids the overhead of a networked database for local desktop sessions.

Workspace KV Store

The WorkspaceKvStore class in apps/server/src/workspace-kv-store.ts exposes a key-value API over a local SQLite file named runtime.sqlite. It builds on Drizzle's sqliteTable and native bun:sqlite or node:sqlite drivers.

Runtime Database Abstraction

The apps/server/src/runtime-db.ts module handles SQLite database creation, migration, and access. It abstracts the native driver selection, allowing OpenWork to run under Bun or Node.js while keeping workspace data isolated.

import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
import { Database } from "bun:sqlite";
import { drizzle } from "drizzle-orm/bun-sqlite";

const dbPath = join(configDir, "runtime.sqlite");
const sqlite = new Database(dbPath, { create: true });
const kv = drizzle(sqlite);

// Define a table for key/value pairs
export const workspaceKv = sqliteTable("workspace_kv", {
  key: text("key").primaryKey(),
  value: text("value"),
});

(source: apps/server/src/workspace-kv-store.ts and apps/server/src/runtime-db.ts)

Drizzle ORM as the Unified Database Layer

Drizzle ORM is the single abstraction used across both database technologies in OpenWork. The enterprise package relies on drizzle-orm/mysql-core, while the server runtime uses drizzle-orm/sqlite-core. Migration scripts for the MySQL layer are generated via Drizzle-Kit, configured in ee/packages/den-db/drizzle.config.ts.

This dual-engine approach lets OpenWork maintain a full-featured relational model for shared enterprise data while keeping local state lightweight and portable.

Summary

  • MySQL powers the core enterprise backend for organizations, users, and policies through the @openwork-ee/den-db package.
  • SQLite handles per-workspace configuration and temporary caches via a local runtime.sqlite file.
  • Both engines are accessed through Drizzle ORM, ensuring type-safe queries and schema management.
  • The codebase contains no PostgreSQL, MongoDB, or other database drivers, confirming a focused MySQL-plus-SQLite stack.

Frequently Asked Questions

Does OpenWork support PostgreSQL or MongoDB?

No. A full search of the different-ai/openwork codebase reveals no PostgreSQL or MongoDB clients, drivers, or schemas. The only database technologies used in OpenWork are MySQL and SQLite.

Can OpenWork use PlanetScale instead of a self-hosted MySQL database?

Yes. The MySQL client in ee/packages/den-db/src/client.ts can connect through drizzle-orm/planetscale-serverless, making PlanetScale a fully supported drop-in replacement for standard MySQL.

Why does OpenWork use SQLite if MySQL is already available?

SQLite serves a different purpose: it stores local workspace state, session caches, and per-desktop configuration. Using a file-based engine eliminates network latency and server setup for individual user environments, while MySQL remains reserved for shared, persistent enterprise data.

What ORM does OpenWork use for its database layers?

OpenWork uses Drizzle ORM exclusively. It leverages mysql-core and sqlite-core packages alongside Drizzle-Kit for type-safe schema definitions, query building, and migrations across both engines.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →