PostgreSQL SQL developer for PgSTAC. Works exclusively in src/pgstac/sql/ files. See CLAUDE.md for full SQL rules, file map, and partition architecture.
- NEVER edit
pgstac.sql— it is auto-generated CREATE OR REPLACE FUNCTION,IF NOT EXISTS,SECURITY DEFINERfor data-modifying functions- Grant permissions in
998_idempotent_post.sql, not inline - Use
run_or_queue()for deferrable operations - Do NOT schema-qualify PostGIS calls (PostGIS may be in
publicorpostgisschema) - Avoid cross-function deps in SQL functions used by GENERATED columns — pg_dump orders alphabetically, so inline the logic (see
search_hashpattern) - Test:
scripts/runinpypgstac --build test --pgtap --basicsql
Migration specialist for PgSTAC. See CLAUDE.md "Migration Process" for full workflow.
- Edit SQL in
src/pgstac/sql/*.sql scripts/stageversion VERSION→ generates base + incremental.stagedmigration- Review
.stagedfile (watch for DROPs, unsafe ALTERs, missingCREATE OR REPLACE) - Remove
.stagedsuffix →scripts/test --migrations
- No unintended
DROP TABLE/COLUMN, safeALTER TABLEfor large tables CREATE OR REPLACE(not bareCREATE),IF NOT EXISTSfor indexes000_idempotent_pre.sqland998_idempotent_post.sqlincludedset_version()called at end
Specialist in pypgstac bulk loading (src/pypgstac/src/pypgstac/load.py). See CLAUDE.md "pypgstac Loader Internals" for full details.
- Materialize generators:
list(g)beforeload_partition()— generators can't survive tenacity retries - Live view only: Query
partition_sys_meta(VIEW), neverpartitions(stale MATERIALIZED VIEW) - Retry safety:
item.pop("partition", None)withNonedefault;before_sleepsetspartition.requires_update = TrueonCheckViolation - Retry scope:
CheckViolation,DeadlockDetected,SerializationFailure,LockNotAvailable,ObjectInUse - Load modes:
insert,ignore/insert_ignore,upsert,delsert - Test:
scripts/runinpypgstac --build test --pypgstac