Documentation

Everything you need to know about designing database schemas with SchemaFlow.

Quick Start

SchemaFlow is a visual database schema designer that runs entirely in your browser. Here's how to get started in under a minute:

  1. Open the Designer — Click "Start Designing" to open the canvas
  2. Add a Table — Click the "Add Table" button in the sidebar
  3. Add Columns — Click on a table and use the inspector panel to add columns
  4. Create Relations — Drag from one column to another to create a foreign key
  5. Export — Click the export button and choose your format

Creating Tables

To create a new table, click the "Add Table" button in the left sidebar. A new table will appear on the canvas with:

  • A default id column (UUID with auto-generation)
  • created_at and updated_at timestamp columns

You can rename the table by clicking on its name in the inspector panel or by double-clicking the table header on the canvas.

Adding Columns

Select a table by clicking on it, then use the inspector panel on the right to:

  • Add new columns with the "Add Column" button
  • Set the column name and type
  • Configure constraints (primary key, nullable, unique)
  • Set default values

Creating Relations

Relations represent foreign key constraints between tables. To create a relation:

  1. Hover over the source column (the one that will have the foreign key)
  2. Click and drag from the connection handle on the right side
  3. Drop on the target column (usually a primary key in another table)

The relation will be created with default settings (one-to-many, ON DELETE CASCADE). You can modify these settings in the inspector panel when the relation is selected.

PostgreSQL Export

The PostgreSQL exporter generates standard SQL DDL statements including:

  • CREATE TYPE statements for enums
  • CREATE TABLE statements with all columns and constraints
  • Primary key and unique constraints
  • Foreign key constraints with ON DELETE/ON UPDATE actions
  • Default values and NOT NULL constraints

Example output:

CREATE TABLE "users" (
  "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  "email" VARCHAR(255) NOT NULL UNIQUE,
  "name" VARCHAR(100),
  "created_at" TIMESTAMPTZ NOT NULL DEFAULT now(),
  "updated_at" TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE "posts" (
  "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  "title" VARCHAR(255) NOT NULL,
  "content" TEXT,
  "author_id" UUID NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
  "created_at" TIMESTAMPTZ NOT NULL DEFAULT now(),
  "updated_at" TIMESTAMPTZ NOT NULL DEFAULT now()
);

Prisma Export

The Prisma exporter generates a complete schema.prisma file including:

  • Model definitions with proper field types
  • Relation directives (@relation)
  • Field attributes (@id, @unique, @default)
  • Enum definitions

Example output:

model User {
  id        String   @id @default(uuid())
  email     String   @unique
  name      String?
  posts     Post[]
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Post {
  id        String   @id @default(uuid())
  title     String
  content   String?
  author    User     @relation(fields: [authorId], references: [id], onDelete: Cascade)
  authorId  String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Drizzle Export

Coming Soon

Drizzle export will generate TypeScript schema files with full type safety.

TypeORM Export

Coming Soon

TypeORM export will generate entity classes with decorators.

Supported Column Types

CategoryTypes
IdentifiersUUID, Serial, BigSerial
NumericInteger, BigInt, SmallInt, Decimal, Numeric, Real, Double
TextVarchar, Text, Char
Date/TimeDate, Time, Timestamp, Timestamp with Time Zone
JSONJSON, JSONB
OtherBoolean, Bytea, Enum

Enums

You can create custom enum types for columns. Enums are defined globally and can be used by any column in any table. The exporter will generate the appropriate enum definition for each target format.

Relationship Types

  • One-to-One — Each record in table A relates to exactly one record in table B
  • One-to-Many — Each record in table A can relate to multiple records in table B (most common)
  • Many-to-Many — Records in table A can relate to multiple records in table B and vice versa (requires a junction table)

Import/Export JSON

You can export your entire schema as a JSON file for backup or sharing. This JSON can be imported later to restore your work. Use the toolbar buttons:

  • Export JSON — Downloads your schema as a .json file
  • Import JSON — Loads a previously exported schema

Note: Importing will replace your current schema.

Roadmap

We're actively working on new features:

  • ✅ PostgreSQL export
  • ✅ Prisma export
  • 🔜 Drizzle export
  • 🔜 TypeORM export
  • 🔜 MySQL/SQLite support
  • 🔜 Undo/Redo
  • 🔜 SQL import
  • 🔜 PNG/SVG diagram export
  • 🔜 Schema templates (blog, SaaS, e-commerce)

Need Help?

If you have questions or run into issues, please open an issue on GitHub or reach out on Twitter.