Avoided transactional DDL on castrated databases.

Fixed a test failure that appeared after 753a22a6, although the bug
existed before that commit.

Refs #22308.