PgDesigner

Quick Start — PostgreSQL Schema Designer

This guide takes you from zero to a working schema in 5 minutes.

1. Install

brew tap vmkteam/tap
brew install pgdesigner

Or download the binary for your platform.

2. Open the visual editor

pgdesigner

This starts a local server and opens PgDesigner in your browser. The Welcome Screen offers five sample databases — or click New Project.

The Project Settings dialog opens. Name the project (e.g., shop) and set Naming → Convention to snake_case — the default is camelCase. Click Save.

3. Create your first table

  1. Click ⊞T in the toolbar (or press T), then click an empty spot on the canvas
  2. Enter the table name — users
  3. The Table Editor opens with a primary key already in place: user_id integer, an identity column
  4. Click + Add, type email, press Tab, type varchar(255), press Enter
  5. Add created_at with type timestamptz and set Default to now() in the side panel
  6. Click Save

New columns are NOT NULL by default — that's a project setting too.

4. Add a second table with a foreign key

  1. Create another table the same way — orders. It gets order_id as its primary key
  2. Click →FK in the toolbar (or press F)
  3. Click orders, then click users
  4. PgDesigner adds a user_id column to orders, the fk_orders_user_id foreign key, and an ix_orders_user_id index on it
PgDesigner ERD canvas with users and orders tables connected by fk_orders_user_id foreign key in light theme

5. Generate SQL

Press Ctrl+G (⌘+G on macOS), or Database → Generate DDL…:

CREATE TABLE "users" (
	"user_id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
	"email" varchar(255) NOT NULL,
	"created_at" timestamptz NOT NULL DEFAULT now(),
	CONSTRAINT "pk_users" PRIMARY KEY("user_id")
);

CREATE TABLE "orders" (
	"order_id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
	"user_id" integer,
	CONSTRAINT "pk_orders" PRIMARY KEY("order_id")
);

CREATE INDEX "ix_orders_user_id" ON "orders" (
	"user_id"
);

ALTER TABLE "orders" ADD CONSTRAINT "fk_orders_user_id" FOREIGN KEY ("user_id")
	REFERENCES "users"("user_id")
	ON DELETE RESTRICT
	ON UPDATE RESTRICT
	NOT DEFERRABLE;

Foreign keys always come after all tables are created. Copy the SQL, save it with Save .sql…, or pipe it to psql from the CLI with pgdesigner generate.

6. Lint your schema

Press Ctrl+L (⌘+L) or Diagram → Check Diagram. PgDesigner runs 69 rules and reports errors, warnings, and suggestions — fixable issues get a fix button.

7. Save and commit

Press Ctrl+Shift+S (File → Save As…) and save the project into your repository as a .pgd file. Then commit it:

git add shop.pgd
git commit -m "Initial schema: users + orders"

From now on, every schema change produces a clean single-line diff in your pull requests.

Next steps