BlogPricing
Back to insights
TutorialNovember 20, 2026 · Updated November 24, 2026

Database schema diagram generator with real SQL export

Raltey turns a prompt into an ERD, then exports PostgreSQL DDL, Prisma, Drizzle, TypeScript, Zod, Go, or Python. Here is what each format does, and what the tool does not do.

Author
VyersFounder of Raltey

Database schema diagram generator with real SQL export

Raltey's database schema canvas is a visual ERD tool with code exports. You describe the tables and relations, the AI agent drafts them on a structured canvas, and the export panel turns the same schema into PostgreSQL DDL, Prisma, Drizzle, TypeScript, Zod, Go, or Python. The SQL output is PostgreSQL-specific, not a generic SQL dialect.

What the export actually produces

The SQL generator creates CREATE TABLE statements with quoted table and column names. It uses SERIAL for integer auto-increment fields and BIGSERIAL for bigint fields. Foreign keys are emitted as ALTER TABLE statements after the tables.

A small schema looks like this:

-- Generated by Raltey
-- 2026-11-20T10:00:00.000Z

CREATE TABLE "users" (
  "id" SERIAL PRIMARY KEY,
  "email" VARCHAR(255) NOT NULL UNIQUE,
  "created_at" TIMESTAMP NOT NULL
);

CREATE TABLE "posts" (
  "id" SERIAL PRIMARY KEY,
  "author_id" INTEGER NOT NULL,
  "title" TEXT NOT NULL,
  "published_at" TIMESTAMP
);

-- Foreign Keys
ALTER TABLE "posts" ADD CONSTRAINT "fk_posts_author_id" FOREIGN KEY ("author_id") REFERENCES "users" ("id");

The exact output depends on the fields and relations you define. The generator is deliberately simple, so review the result before you run it against a real database.

When to use each export

FormatGood forWatch out for
PostgreSQL DDLA new Postgres schema, a migration draft, a review artifactIt is Postgres-specific. Check types and defaults.
PrismaA TypeScript backend that already uses PrismaThe generated datasource uses PostgreSQL and DATABASE_URL.
DrizzleA TypeScript backend that uses Drizzle ORMReview table and column names against your naming conventions.
TypeScriptShared types for an API or frontendTypes describe the shape, not the database constraints.
ZodRuntime validation at API boundariesKeep it in sync with the database schema.
GoGo services and structsCheck nullability and JSON tags.
PythonPython services, scripts, or data jobsCheck the typing style against your project.

A workflow that produces a usable schema

1. Start with the questions, not the tables

Write down the nouns in your product: user, workspace, project, document, invitation, subscription. Those are candidate tables. Then write the verbs: creates, joins, owns, pays. Those are candidate relations.

2. Ask the agent for a first pass

A prompt like this gives the agent enough structure:

Create a PostgreSQL schema for a SaaS app. Tables: users, workspaces, workspace_members, projects, documents. A workspace has many members. A project belongs to one workspace. A document belongs to one project. Include created_at and updated_at timestamps.

The agent produces nodes and connections on the database schema canvas. You can then edit fields, keys, and relations directly.

3. Review the keys

Check these before you export:

  • Every table has a primary key.
  • Every foreign key points at the right table and field.
  • Nullable fields are intentional.
  • Auto-increment fields are the ones you actually want to auto-generate.
  • Timestamps exist where your application expects them.

4. Export the code

Open the download menu, choose Schema, then pick a format. The panel shows the generated code with syntax highlighting. Copy it, or download the file.

5. Review the diff

Do not treat generated DDL as a migration. Treat it as a draft. Compare it with your existing schema, check the types, and decide what needs a migration tool.

What Raltey does not do

This part matters if you are evaluating the tool:

  • No live database introspection. Raltey does not connect to your database and read the current schema.
  • No MySQL, SQL Server, or SQLite DDL. The SQL export is PostgreSQL.
  • No DBML import or export. If your team writes DBML by hand, dbdiagram.io is a better fit for that workflow.
  • No automatic migration generation. You still need your migration tool.
  • No schema sync from a repository. GitHub nodes can link a diagram to files, but Raltey does not parse migrations into tables.

Those limits are why the export panel matters. The diagram is a design surface, and the code is the handoff.

Where the diagram fits in a repo

A schema diagram is most useful when it links to the code that implements it:

  • Put the schema canvas in a Raltey project next to the architecture diagram.
  • Add GitHub nodes for the migration folder and the data access layer.
  • Write the naming conventions and ownership notes in the project docs.
  • Save a named version before a large schema change.

The diagram does not replace migrations. It makes the shape of the schema reviewable by people who do not want to read a migration diff.

A short evaluation checklist

  • Can you draw the tables and relations without fighting the canvas?
  • Can the AI edit one table without rebuilding the rest?
  • Do the foreign keys survive the export?
  • Does the export match the stack you actually use?
  • Can you keep the diagram and the docs in one project?
  • Can you restore an earlier version after a bad change?

If those answers line up, the tool is useful. If you need DBML round-trip or live introspection, Raltey is not the right fit yet.

FAQ

Does Raltey generate MySQL or SQLite DDL?

No. The SQL export produces PostgreSQL DDL. It uses quoted identifiers and SERIAL or BIGSERIAL for auto-increment fields.

Can Raltey read an existing database and draw the schema?

Not today. There is no live database introspection. You can describe the schema to the AI agent or draw the tables by hand, then export the code.

Does the Prisma export use PostgreSQL?

Yes. The generated Prisma schema declares the postgresql provider and reads the connection string from DATABASE_URL.

Which code formats can I export from a database schema?

PostgreSQL DDL, Prisma, Drizzle, TypeScript, Zod, Go, and Python.

Is SQL export limited to a paid plan?

The export panel is available from the database schema canvas. The Free plan can create database schema projects. SVG export starts on Starter and PDF on Pro.

Try it with your own schema: create a database schema project, or read the database schema guide and the database design use case.