Loading...
Loading...
Postgres schema and query rules, independent of the calling language. TRIGGER — load BEFORE writing or editing a .sql file, a migration, or any schema, index, constraint or query change against Postgres: new tables, foreign keys, status columns, claim or lease queries, backfills, ON CONFLICT upserts. SKIP for MySQL, SQLite and other engines, and for code that never touches SQL.
npx skill4agent add o-marsters-1997/my-claude-code postgres-best-practicesgo-idiomaticreferences/database.mdreferences/patterns.md| If you're working on… | Load this |
|---|---|
Go code that runs these queries ( | |
| A closed value set mirrored as a Go type | |
| Writing or changing a migration, any tool | |
Converting an existing Postgres | |
| Migrations in a repo that uses goose | |
Only if the repo has | |
textCHECKENUMENUMCHECKALTERENUMON DELETE CASCADEtimestamptzdatetextjsonbtext<table>_<cols>_key_fkey_check<table>_<cols>_idx''NOT NULL DEFAULT ''DELETE ... WHERE id IN (SELECT id ... LIMIT n)DEFAULT now()NOW()time.Now()SELECT *RETURNING *LIMITWHERE (created_at, id) < ($1, $2) ORDER BY created_at DESC, id DESC LIMIT $3OFFSET= ANY($1::uuid[])VALUESCOPYFOR UPDATE SKIP LOCKEDSELECT ... FOR UPDATE23505ON CONFLICTON CONFLICT (col)ON CONSTRAINT nameON CONFLICT DO NOTHINGNOT NULLUPDATECREATE INDEX CONCURRENTLYADD CONSTRAINT ... NOT VALIDVALIDATE CONSTRAINT