Not possible to upgrade a store with version 'v0.A.7' to current store version `SF4.0.0` (Neo4j 4.0.0) error when upgrading from neo4j 3.5.14 to 4.0.0

Our current neo4j version is 3.1.6. We want to upgrade to neo4j version 4.0. We first upgraded from 3.1.6 to 3.5.14 which worked. But migrating from 3.5.14 to 4.0.0 is throwing the following error:

Caused by: org.neo4j.kernel.impl.storemigration.StoreUpgrader$UnexpectedUpgradingStoreVersionException: Not possible to upgrade a store with version 'v0.A.7' to current store
version SF4.0.0 (Neo4j 4.0.0).

Looks like you didn't do a migration on the upgrade, since the store format post-migration to 3.5.x should be 'v0.A.9'.

Make sure the following config setting is set to true when you start up the store in 3.5.x:
dbms.allow_format_migration=true