[1.7.x] Used migration framework in GIS test tearDown

Backport of 48c4ea414 from master.
[1.7.x] Added Spatialite support to the new migration framework

Refs #22451.
Backport of 2ffa6ca73a from master.
[1.7.x] Fixed #22486 -- Restored the ability to reverse views created using functools.partial.

Regression in 8b93b31487d6d3b0fcbbd0498991ea0db9088054.

Thanks rcoup for the report.

Backport of 3c06b2f2a3 from master
[1.7.x] Fixed #22495 -- Locmem cache.add() failed with infinite timeouts

cache.add() incorrectly succeeded when there was an existing key
with an infinite (None) timeout.
Backport of af5f688392 from master.
[1.7.x] Set compile messages options as class variable

Refs #18714. Same logic as options for makemessages commands.
Backport of 3a435a057 from master.
[1.7.x] Wrapped migrations in a transaction only on DBs with transactional DDL.

Backport of e74d2183 from master
[1.7.x] Used the same instance of atomic for entry and exit.

Since all state is maintained on the connection at this time and none in
the atomic, it doesn't matter, but it could introduce some subtle bugs
if the implementation changed in the future.

Backport of 0aa4c6c3 from master