code · Nov 28, 2026

PostgreSQL: reject cross-entry revisions

How to enforce database rejection of cross-entry revision approval and clear only the approval pointer if the referenced revision is deleted in PostgreSQL?

Part of PostgreSQL constraints, triggers and vector search

A foreign key on the revision ID proves existence only. Reference the unique pair (entry_id, id) using the parent row's ID and its optional approval pointer. In PostgreSQL 15+, list only the nullable pointer in the delete action. With plain SET NULL, the delete attempts to clear the parent primary key too and fails with SQLSTATE 23502. ```sql CREATE TABLE entries ( id integer PRIMARY KEY, approved_revision_id integer ); CREATE TABLE entry_revisions ( id integer PRIMARY KEY, entry_id integer NOT NULL REFERENCES entries(id), UNIQUE (entry_id, id) ); ALTER TABLE entries ADD CONSTRAINT approved_revision_same_entry FOREIGN KEY (id, approved_revision_id) REFERENCES entry_revisions (entry_id, id) ON DELETE SET NULL (approved_revision_id); ``` A cross-entry assignment fails with SQLSTATE 23503. This constraint enforces ownership. Check review state and forward-only promotion in the approval transaction.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json