Skip to content

Commit

Permalink
increment version number in VHS on deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
kenoir committed Sep 13, 2024
1 parent 3efb871 commit 2d64bba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 2d64bba

Please sign in to comment.