use of org.neo4j.storageengine.api.StoreVersion in project neo4j by neo4j.
the class SchemaIndexMigrator method migrate.
@Override
public void migrate(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo, IndexImporterFactory indexImporterFactory) {
StoreVersion fromVersion = storageEngineFactory.versionInformation(versionToMigrateFrom);
StoreVersion toVersion = storageEngineFactory.versionInformation(versionToMigrateTo);
deleteAllIndexes = checkIndexCapabilities && !fromVersion.hasCompatibleCapabilities(toVersion, CapabilityType.INDEX);
deleteRelationshipIndexes = !fromVersion.hasCompatibleCapabilities(toVersion, CapabilityType.FORMAT);
}
use of org.neo4j.storageengine.api.StoreVersion in project neo4j by neo4j.
the class StoreUpgrader method migrateIfNeeded.
/**
* Upgrade the store format, if it is not the latest version or is different from the configured desired format.
*
* @param layout The layout of the existing database store.
* @param forceUpgrade If {@code true}, the value of the {@link GraphDatabaseSettings#allow_upgrade} setting is ignored.
*/
public void migrateIfNeeded(DatabaseLayout layout, boolean forceUpgrade) throws IOException {
// nothing to migrate
if (!Files.exists(layout.databaseDirectory())) {
return;
}
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(STORE_UPGRADE_TAG))) {
DatabaseLayout migrationStructure = DatabaseLayout.ofFlat(layout.file(MIGRATION_DIRECTORY));
cleanupLegacyLeftOverDirsIn(layout.databaseDirectory());
Path migrationStateFile = migrationStructure.file(MIGRATION_STATUS_FILE);
// if migration directory exists than we might have failed to move files into the store dir so do it again
if (hasCurrentVersion(storeVersionCheck, cursorContext) && !fileSystem.fileExists(migrationStateFile)) {
// No migration needed
return;
}
if (isUpgradeAllowed() || forceUpgrade) {
migrate(layout, migrationStructure, migrationStateFile, cursorContext);
} else {
Optional<String> storeVersion = storeVersionCheck.storeVersion(cursorContext);
if (storeVersion.isPresent()) {
StoreVersion version = storeVersionCheck.versionInformation(storeVersion.get());
if (version.hasCapability(IndexCapabilities.LuceneCapability.LUCENE_5)) {
throw new UpgradeNotAllowedException("Upgrade is required to migrate store to new major version.");
} else {
String configuredVersion = storeVersionCheck.configuredVersion();
if (configuredVersion != null && !version.isCompatibleWith(storeVersionCheck.versionInformation(configuredVersion))) {
throw new UpgradeNotAllowedException();
}
}
}
}
}
}
Aggregations