RippleDB
RippleDB
Reference

@rippledb/cli

CLI tools for RippleDB - schema codegen and utilities

@rippledb/cli

CLI tools for RippleDB, including schema codegen from external sources like Drizzle.

Installation

pnpm add -D @rippledb/cli
npm install -D @rippledb/cli
yarn add -D @rippledb/cli

Commands

rippledb generate

Generates RippleDB schemas from configured sources (currently Drizzle).

npx rippledb generate
npx rippledb generate --config custom.config.ts
OptionDescriptionDefault
-c, --config <path>Path to config fileripple.config.ts

Configuration

Create a ripple.config.ts file in your project root:

import { defineConfig } from "@rippledb/cli/config";

export default defineConfig({
  codegen: {
    drizzle: {
      entities: "./src/db/ripple-entities.ts",
      output: "./src/shared/schema.ts",
    },
  },
});

The CLI validates this config at runtime using a small valibot schema, so typos or missing keys throw a helpful error before generation starts.

Configuration Options

codegen.drizzle

Generate RippleDB schema from Drizzle tables.

OptionTypeDescription
entitiesstringPath to file exporting Drizzle tables
outputstringOutput path for generated schema

Drizzle Codegen

Setup

  1. Create an entities file that exports the Drizzle tables you want in RippleDB:
// src/db/ripple-entities.ts
export { todos, users } from "./schema";
// Only export tables you want as RippleDB entities
  1. Configure the CLI in ripple.config.ts:
import { defineConfig } from "@rippledb/cli/config";

export default defineConfig({
  codegen: {
    drizzle: {
      entities: "./src/db/ripple-entities.ts",
      output: "./src/shared/schema.ts",
    },
  },
});
  1. Run the generator:
npx rippledb generate

Generated Output

The CLI generates a RippleDB schema file:

// AUTO-GENERATED by @rippledb/cli vx.x.x - DO NOT EDIT
// Source: ./src/db/ripple-entities.ts

import { defineSchema, s, type InferSchema } from "@rippledb/core";

export const schema = defineSchema({
  todos: {
    id: s.string(),
    title: s.string(),
    done: s.boolean(),
    createdAt: s.string().optional(),
  },
  users: {
    id: s.string(),
    name: s.string(),
    email: s.string(),
  },
});

export type Schema = InferSchema<typeof schema>;

Type Mapping

Drizzle TypeRippleDB Type
text, varchar, char, uuids.string()
integer, smallint, bigint, real, float, decimals.number()
booleans.boolean()
Nullable columns.optional()

Unknown Drizzle types default to s.string() with a console warning.

Workflow Integration

Package.json Script

Add a generate script to your package.json:

{
  "scripts": {
    "generate": "rippledb generate",
    "postinstall": "rippledb generate"
  }
}

Pre-commit Hook

Generate schema before commits to keep it in sync:

# .husky/pre-commit
npx rippledb generate
git add src/shared/schema.ts

CI/CD

Run generation in your CI pipeline:

# .github/workflows/ci.yml
- name: Generate RippleDB schema
  run: npx rippledb generate

Why Use Codegen?

When using Drizzle as your database layer:

  • Drizzle is the source of truth - migrations, schema changes happen in Drizzle
  • No duplication - RippleDB schema is derived, not manually maintained
  • Type safety flows through - Drizzle types → RippleDB types → Frontend types
  • Frontend stays clean - No drizzle-orm dependency in your frontend bundle
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Drizzle Schema │ ──► │ rippledb gen    │ ──► │ RippleDB Schema │
│  (DB source)    │     │                 │     │ (Frontend-safe) │
└─────────────────┘     └─────────────────┘     └─────────────────┘


    Migrations

On this page