Use pg-aiguide for PostgreSQL docs and best practices
Shows how to use the pg-aiguide connector for PostgreSQL work: confirm the version and scope, choose between manual search and curated playbooks, and phrase queries that land on the right section. It is read-only and never touches your database.
Use it when
- Asking how a PostgreSQL feature or clause behaves in a specific version
- Designing a schema and wanting current best practice pulled in
- Decoding a PostgreSQL error message against the official manual
Tools it uses
search_docsview_skill
Using PostgreSQL 16, how do I write an upsert that only updates when the incoming row is newer?
Assuming PostgreSQL 16, use INSERT ... ON CONFLICT (id) DO UPDATE with a WHERE clause on the update, comparing excluded.updated_at to the stored updated_at. The manual's ON CONFLICT section documents the excluded row. I checked this against the upsert excerpt; I have not run it against your table, so run it there to confirm.