From 9f8c3808e834aaca985500c3415d893e6ace6cf0 Mon Sep 17 00:00:00 2001 From: Philipp Zehnder Date: Mon, 13 Nov 2023 09:08:49 +0100 Subject: [PATCH] bug(#2165): Fix migration for adapter instances (#2167) --- .../service/core/migrations/v093/AdapterMigration.java | 4 +++- .../migrations/v093/migrator/SpecificAdapterMigrator.java | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/AdapterMigration.java b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/AdapterMigration.java index 29fd205ab3..0e488db656 100644 --- a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/AdapterMigration.java +++ b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/AdapterMigration.java @@ -111,7 +111,9 @@ public void executeMigration() { LOG.info("Performing backup of old models to database adapterinstance_backup"); adaptersToMigrate.forEach(adapter -> { - new AdapterBackupWriter(adapterInstanceBackupClient, new MigrationHelpers()).writeBackup(adapter); + // Is required to keep the _rev field for the original object. This field must be removed for the backup + var copyAdapter = adapter.deepCopy(); + new AdapterBackupWriter(adapterInstanceBackupClient, new MigrationHelpers()).writeBackup(copyAdapter); }); LOG.info("Performing migration of adapters"); diff --git a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/migrator/SpecificAdapterMigrator.java b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/migrator/SpecificAdapterMigrator.java index 0c5a7765a5..7c77c2f253 100644 --- a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/migrator/SpecificAdapterMigrator.java +++ b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/migrator/SpecificAdapterMigrator.java @@ -44,6 +44,8 @@ public void migrate(CouchDbClient couchDbClient, var adapterName = helpers.getAdapterName(adapter); var convertedAdapter = converter.convert(adapter); + LOG.info("Start migrating adapter {}", adapterName); + couchDbClient.update(convertedAdapter); LOG.info("Successfully migrated adapter {}", adapterName);