Sounds very hard to me. How do you handle online schema changes with this? Schema changes are trivial to do if you can be down for a long time.
You can only do those if schema changes are transactional. The transaction could update the checksum and return it for the caller to use in subsequent calls.
And yes, that would shut off other clients that want to be sure to talk to the correct schema, but if you opt in to such a scheme, that’s what you want.
Could be as simple as secure hashing the old hash with the text of the DDL command appended.
That would mean two databases can be identical, structure-wise, but have different hashes (for example if tables are created in a different order), but would that matter in practice?
Alternatively, they can keep a hash for every table, index, constraint, etc. and XOR them to get the database hash.