LPS-34648 Prevent NPE when upgrading inconsistent databases