FREE TOOL

SQL to Drizzle schema converter

Paste your CREATE TABLE statements and get a Drizzle ORM schema — table definitions, column builders, and .references() calls, matching the Postgres/MySQL/SQLite core for your chosen dialect.

YOUR SQL
TYPESCRIPT OUTPUT
// Generated by ERD Factory - review relation/field names before use.
import { boolean, integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
  id: integer("id").primaryKey(),
  email: text("email").notNull(),
  fullName: text("full_name"),
  createdAt: timestamp("created_at"),
  lastLoginAt: timestamp("last_login_at"),
});

export const orders = pgTable("orders", {
  id: integer("id").primaryKey(),
  userId: integer("user_id").references(() => users.id),
  status: text("status").notNull(),
  totalCents: integer("total_cents").notNull(),
  currency: text("currency"),
  placedAt: timestamp("placed_at"),
  shippedAt: timestamp("shipped_at"),
});

export const orderItems = pgTable("order_items", {
  id: integer("id").primaryKey(),
  orderId: integer("order_id").references(() => orders.id).unique(),
  productId: integer("product_id").notNull(),
  quantity: integer("quantity").notNull(),
});

export const products = pgTable("products", {
  id: integer("id").primaryKey(),
  sku: text("sku").notNull(),
  name: text("name").notNull(),
  priceCents: integer("price_cents").notNull(),
  inventoryCount: integer("inventory_count"),
  active: boolean("active"),
});

export const payments = pgTable("payments", {
  id: integer("id").primaryKey(),
  orderId: integer("order_id").references(() => orders.id).unique(),
  amountCents: integer("amount_cents").notNull(),
  method: text("method").notNull(),
  processedAt: timestamp("processed_at"),
});

export const sessions = pgTable("sessions", {
  id: integer("id").primaryKey(),
  token: text("token").notNull(),
  expiresAt: timestamp("expires_at"),
});

See these 6 tables as an interactive diagram, get AI-suggested fixes, and save your schema — free.

Open in the full editor

Find the gaps before
production does.

Paste a schema and see your first analysis in under ten seconds.

ERD Factory

Schema visualization & analysis for people who ship databases.

© 2026 ERD Factory