Templates:
organizations5 cols
id
uuid
name
varchar
slug
varchar
plan
varchar
created_at
timestamp
users5 cols
id
uuid
organization_id
uuid
email
varchar
role
varchar
is_active
boolean
subscriptions6 cols
id
uuid
organization_id
uuid
provider_id
varchar
status
varchar
price_cents
int
renews_at?
timestamp
audit_logs5 cols
id
serial
user_id?
uuid
action
varchar
metadata?
jsonb
created_at
timestamp
Drag tables to arrange your ERD · Click any table to edit columns & relations
-- Generated by SchemaCost (PostgreSQL 16)
CREATE EXTENSION IF NOT EXISTS "pgcrypto";

CREATE TABLE "organizations" (
  "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  "name" VARCHAR(255) NOT NULL,
  "slug" VARCHAR(255) NOT NULL UNIQUE,
  "plan" VARCHAR(255) NOT NULL DEFAULT 'free',
  "created_at" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE "users" (
  "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  "organization_id" UUID NOT NULL REFERENCES "organizations"("id") ON DELETE CASCADE,
  "email" VARCHAR(255) NOT NULL UNIQUE,
  "role" VARCHAR(255) NOT NULL DEFAULT 'member',
  "is_active" BOOLEAN NOT NULL DEFAULT true
);

CREATE TABLE "subscriptions" (
  "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  "organization_id" UUID NOT NULL UNIQUE REFERENCES "organizations"("id") ON DELETE CASCADE,
  "provider_id" VARCHAR(255) NOT NULL UNIQUE,
  "status" VARCHAR(255) NOT NULL,
  "price_cents" INTEGER NOT NULL,
  "renews_at" TIMESTAMPTZ
);

CREATE TABLE "audit_logs" (
  "id" BIGSERIAL PRIMARY KEY,
  "user_id" UUID REFERENCES "users"("id") ON DELETE SET NULL,
  "action" VARCHAR(255) NOT NULL,
  "metadata" JSONB,
  "created_at" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Foreign Key Indexes
CREATE INDEX "idx_users_organization_id" ON "users" ("organization_id");
CREATE INDEX "idx_subscriptions_organization_id" ON "subscriptions" ("organization_id");
CREATE INDEX "idx_audit_logs_user_id" ON "audit_logs" ("user_id");

7 Production Targets from 1 Diagram

PostgreSQL 16, Supabase with RLS policies, MySQL 8, SQLite/D1, Prisma, Drizzle ORM, and TypeScript kept in perfect sync.

Client-Side .ZIP Starter Kit

Package SQL migrations, ORM files, TypeScript interfaces, and an SVG diagram into a clean .ZIP directly in your browser.

1K to 200K DAU Cloud Cost Simulator

Spot Firestore read spikes and egress traps before launch by comparing 6 cloud database providers side by side.

Specialized Database & Cloud Tools