- Home
- Skills
- Data & Databases
- PostgreSQL Schema Architect
Works with the AI Agents you already use
PostgreSQL Schema Architect
Schema mistakes are the most expensive kind — code refactors in days, but a wrong table design holds your data hostage for years.
$9.99
PostgreSQL Schema Architect
Example session with this skill installed
Design the Postgres schema for a multi-tenant B2B invoicing app: tenants, customers, invoices with line items, and payments. The main queries are listing a tenant's unpaid invoices by due date and monthly revenue reports. We expect a few million invoices per year.
- Read your context and instructions
- Compiled the postgresql schema architect
Schema for multi-tenant invoicing: tenant_id on every table, composite keys for tenant scoping, and monthly range partitioning on invoices.
CREATE TABLE tenant (
tenant_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE customer (
tenant_id bigint NOT NULL REFERENCES tenant,
customer_id bigint GENERATED ALWAYS AS IDENTITY,
name text NOT NULL,
PRIMARY KEY (tenant_id, customer_id)
);
CREATE TABLE invoice (
tenant_id bigint NOT NULL,
invoice_id bigint GENERATED ALWAYS AS IDENTITY,
customer_id bigint NOT NULL,
issued_on date NOT NULL,
due_on date NOT NULL CHECK (due_on >= issued_on),
status text NOT NULL CHECK (status IN ('open','paid','void')),
total_cents bigint NOT NULL CHECK (total_cents >= 0),
PRIMARY KEY (tenant_id, invoice_id, issued_on),
FOREIGN KEY (tenant_id, customer_id) REFERENCES customer
) PARTITION BY RANGE (issued_on);
CREATE INDEX invoice_unpaid_due_idx
ON invoice (tenant_id, due_on) WHERE status = 'open';
Design notes
invoice_lineandpaymentfollow the same pattern, amounts in integer cents.- The partial index serves the unpaid list by due date.
- Monthly partitions on
issued_onkeep revenue reports to few partitions. - Naming: singular snake_case tables,
<table>_idkeys.
Next steps
- Create partitions ahead of time with a scheduled job or pg_partman.
- Add row-level security on
tenant_idfor one shared DB role.
Connects securely to your tools. The creator never sees your data.
About this skill
Schema mistakes are the most expensive kind — code refactors in days, but a wrong table design holds your data hostage for years. This skill designs your PostgreSQL schema from the ground up: table structure, normalization decisions and where to deliberately denormalize, index strategy for your actual query patterns, constraint design that enforces business rules at the database level, and the migration path if you're evolving an existing schema. It explains every decision in terms of the trade-offs specific to your use case — not generic best practices, but choices calibrated to your data volume, query patterns, and growth trajectory. Use it before you write your first CREATE TABLE, or when you've hit the performance wall that tells you the original design was wrong. Give it your domain model and your most expensive queries; it returns a schema you can defend.
- Does not perform live database migrations or execution.
- Limited support for niche extensions outside PostGIS/pg_vector.
- Cannot predict exact hardware-level IOPS bottlenecks.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 4 months ago
Permissions
No special permissions declared or detected