PostgresIntegrationTest applies docs/ddl/postgres.sql on PostgreSQL and
checks that every join and every table possible-value reference between
the workbench's tables has a foreign key, or an exemption with a reason.
The only exemption is sql_workbench_execution.notebook_id, by design: the
execution audit is append-only and outlives its notebook. CASCADE would
delete audit rows, RESTRICT would block deleting any notebook that ever ran
(NotebookTableCustomizer deletes cells, versions, pinned results and shares,
not the audit), SET NULL would rewrite audit rows, and the engine records the
client's notebook id even when that notebook was deleted meanwhile, so the
audit insert must never fail on it.
The existing notebook foreign keys stay NO ACTION: NotebookTableCustomizer
deletes the children through QQQ (audits, locks) before the notebook.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The foreign key sql_workbench_result_snapshot.notebook_id had no index.
NotebookService lists a notebook's snapshots by it, the notebook delete
cascade and the child record lock use it, and the notebook page's Runs
list joins executions on notebook_id. The reference DDL and the H2 test
schema add both indexes. The Postgres integration test now fails if any
sql_workbench_ foreign-key column lacks a leading index.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>