From 2d64bba3c6a22a715f8346fb2389ca51d0fb83a4 Mon Sep 17 00:00:00 2001 From: Robert Kenny Date: Fri, 13 Sep 2024 16:15:47 +0100 Subject: [PATCH] increment version number in VHS on deletion --- .../calm_deletion_checker/DeletionMarker.scala | 2 +- .../DeletionMarkerTest.scala | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/calm_adapter/calm_deletion_checker/src/main/scala/weco/pipeline/calm_deletion_checker/DeletionMarker.scala b/calm_adapter/calm_deletion_checker/src/main/scala/weco/pipeline/calm_deletion_checker/DeletionMarker.scala index 1f6f19076f..7cbff42ebc 100644 --- a/calm_adapter/calm_deletion_checker/src/main/scala/weco/pipeline/calm_deletion_checker/DeletionMarker.scala +++ b/calm_adapter/calm_deletion_checker/src/main/scala/weco/pipeline/calm_deletion_checker/DeletionMarker.scala @@ -22,7 +22,7 @@ class DeletionMarker(sourceTable: String)(implicit client: DynamoDbClient) .when(attributeExists("id")) .update( "id" === record.id, - set("isDeleted", true) + set("isDeleted", true) and add("version", 1), ) ) .map(_.toPayload) diff --git a/calm_adapter/calm_deletion_checker/src/test/scala/weco/pipeline/calm_deletion_checker/DeletionMarkerTest.scala b/calm_adapter/calm_deletion_checker/src/test/scala/weco/pipeline/calm_deletion_checker/DeletionMarkerTest.scala index b966348f11..795e91b2ae 100644 --- a/calm_adapter/calm_deletion_checker/src/test/scala/weco/pipeline/calm_deletion_checker/DeletionMarkerTest.scala +++ b/calm_adapter/calm_deletion_checker/src/test/scala/weco/pipeline/calm_deletion_checker/DeletionMarkerTest.scala @@ -31,7 +31,10 @@ class DeletionMarkerTest val targetRecord = rows.head.toPayload val result = deletionMarker(targetRecord) - result.success.value shouldBe targetRecord.copy(isDeleted = true) + result.success.value shouldBe targetRecord.copy( + isDeleted = true, + version = targetRecord.version + 1 + ) getRecordFromTable( targetRecord.id, targetRecord.version, @@ -48,7 +51,10 @@ class DeletionMarkerTest val targetRecord = rows.head.toPayload val result = deletionMarker(targetRecord) - result.success.value shouldBe targetRecord.copy(isDeleted = true) + result.success.value shouldBe targetRecord.copy( + isDeleted = true, + version = targetRecord.version + 1 + ) getRecordFromTable( targetRecord.id, targetRecord.version, @@ -65,7 +71,10 @@ class DeletionMarkerTest val targetRecord = records.head.toPayload val result = deletionMarker(targetRecord) - result.success.value shouldBe targetRecord.copy(isDeleted = true) + result.success.value shouldBe targetRecord.copy( + isDeleted = true, + version = targetRecord.version + 1 + ) getRecordFromTable( targetRecord.id, targetRecord.version,