Scheduled database health
Opt a stored connection into a weekly audit, no migration needed: unused, redundant and invalid indexes, foreign keys with no index behind them, constraints left NOT VALID, tables never analysed or scanned end to end, tables without a primary key. Hosted, Team and above.
Migrations are checked when they arrive. The things that go wrong between migrations are not: the index nobody reads any more that every write still pays for, the foreign key added without an index behind it, the CONCURRENTLY build that failed at 3 am and left an invalid index, the constraint added NOT VALID that nobody validated. Switch on Weekly health for a connection and once a week the service reads its schema snapshot, structure and counters only, never rows, and runs eight rules over it.
The result is a check in the run log with source "health", one finding per hazard with the statement that fixes it (DROP INDEX CONCURRENTLY, VALIDATE CONSTRAINT, REINDEX INDEX CONCURRENTLY, ANALYZE), and it goes out on the same Slack, Discord and webhook channels as a migration check. A Health button on the Connections page runs one on demand, opted in or not.
Careful by construction
"Unused" needs at least a week of statistics since the last reset and an index of a megabyte or more. Unique and primary indexes are never called unused or redundant. Partial and expression indexes are never called redundant. Sequential-scan findings need a large table. A connection the health poller cannot reach is skipped, not reported.
The CLI is open source and needs no account: npx bolvrk check migration.sql