This guide takes you from zero to a working schema in 5 minutes.
brew tap vmkteam/tap
brew install pgdesigner Or download the binary for your platform.
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.
usersuser_id integer, an identity columnemail, press Tab, type varchar(255), press Entercreated_at with type timestamptz and set Default to now() in the side panelNew columns are NOT NULL by default — that's a project setting too.
orders. It gets order_id as its primary keyorders, then click usersuser_id column to orders, the fk_orders_user_id foreign key, and an ix_orders_user_id index on it
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.
Press Ctrl+L (⌘+L) or Diagram → Check Diagram. PgDesigner runs 69 rules and reports errors, warnings, and suggestions — fixable issues get a fix button.
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.