/db-architect-skills:postgresqlfrom db-architect-skills
PostgreSQL table design: type choices, PG-specific traps, constraints, index types, partitioning, JSONB. Read when writing or reviewing any Postgres schema, including through Prisma or Drizzle.
Ships in db-architect-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
BIGINT GENERATED ALWAYS AS IDENTITY. UUID only when IDs must be opaque, client-generated or merged across systems; then uuidv7() (PG18+) or gen_random_uuid(). Append-only event/log tables may skip a PK.NOT NULL wherever the domain requires a value. Defaults for common values.snake_case; never quoted mixed-case names.UNIQUE (...) NULLS NOT DISTINCT (PG15+) when one NULL is the limit.CHECK (price > 0) allows a NULL price. Pair with NOT NULL.NUMERIC(2,0) errors instead of rounding.CLUSTER is one-off.fillfactor=90.now(), gen_random_uuid()) rewrites the table. Constant defaults are instant.CREATE INDEX CONCURRENTLY cannot run inside a transaction.ON CONFLICT target. Partial indexes do not qualify.| Use | Type | Never |
|---|---|---|
| IDs | BIGINT GENERATED ALWAYS AS IDENTITY | SERIAL |
| Integers | BIGINT (or INTEGER when range is known) | |
| Money | NUMERIC(p,s) | MONEY, REAL, DOUBLE PRECISION |
| Strings | TEXT + CHECK (length(col) <= n) if a limit is needed | VARCHAR(n), CHAR(n) |
| Timestamps | TIMESTAMPTZ | TIMESTAMP, TIMETZ, TIMESTAMPTZ(0) |
| Dates / durations | DATE, INTERVAL | |
| Booleans | BOOLEAN NOT NULL | nullable boolean unless tri-state is intended |
| Fixed small sets | ENUM only for truly stable sets (weekdays). Business statuses: TEXT + CHECK or lookup table | |
| Semi-structured | JSONB | JSON (only if key order must be preserved) |
| Tags, small lists | TEXT[] with GIN; junction table when it is really a relation | |
| Ranges / scheduling | tstzrange, daterange with GiST; [) bounds by default | |
| Case-insensitive match | expression index on LOWER(col); CITEXT only for case-insensitive PK/UNIQUE | |
| Full-text | TSVECTOR with GIN; always pass the language: to_tsvector('english', col) | one-argument to_tsvector |
| Embeddings | vector (pgvector) |
ON DELETE (CASCADE, RESTRICT, SET NULL). DEFERRABLE INITIALLY DEFERRED for circular references.EXCLUDE USING gist (room_id WITH =, period WITH &&) prevents double booking; CHECK cannot.CREATE DOMAIN email AS TEXT CHECK (VALUE ~ '^[^@]+@[^@]+$').GENERATED ALWAYS AS (expr) STORED.INCLUDE (cols) for index-only scans.WHERE status = 'active' for hot subsets.(LOWER(email)); the query must use the identical expression.COPY or multi-row INSERT, UNLOGGED for rebuildable staging.Only for very large tables (>100M rows) where queries filter on the partition key, or where whole partitions are dropped on a schedule. RANGE for time, LIST for discrete regions, HASH when no natural key. Declarative partitioning only; never inheritance. TimescaleDB automates time partitioning, retention and compression.
CREATE INDEX ON t USING GIN (doc). Containment-only workloads: GIN (doc jsonb_path_ops) is smaller but loses ? key-existence support.CHECK (jsonb_typeof(doc) = 'object').pg_trgm (fuzzy LIKE '%x%'), pgvector, timescaledb, postgis, pgcrypto (password hashing), pgaudit. Prefer pgcrypto over uuid-ossp.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (mulosbron/db-architecture-skills) — no native marketplace selected
npx claudepluginhub p/mulosbron-db-architect-skills10 skills in this plugin
/database-adminDatabase operations: backups and restore testing, roles and privileges, destructive commands, maintenance. Read when the task touches a running database rather than its schema design./database-architectChoosing a database and ORM, planning scaling, sharding, caching or replication. Entry point for greenfield data-layer design and for architecture-level audits of an existing system./database-designSchema modeling and schema review: tables, keys, relationships, constraints, indexes, normalization. Use when designing a new schema or auditing an existing one for integrity and performance problems./database-migrationChanging a live database schema safely: zero-downtime column renames and type changes, backfills, rollbacks, moving between databases or ORMs. Read before writing any migration against a database that has data./drizzle-orm-expertDrizzle ORM: schema.ts review, drizzle-kit migration workflow, relational queries, serverless drivers. Read when the project contains drizzle.config.ts./nosql-expertDynamoDB, Cassandra/ScyllaDB and MongoDB data modeling: access-pattern-first design, partition keys, single-table design. Read when designing or auditing a NoSQL schema, or when deciding whether NoSQL fits at all.