fix(portal): don't log soft-deleted deletes (#9698)

This commit is contained in:
Jamil
2025-06-27 12:06:45 -07:00
committed by GitHub
parent 0b09d9f2f5
commit 3247b7c5d2
2 changed files with 20 additions and 1 deletions

View File

@@ -21,7 +21,13 @@ defmodule Domain.ChangeLogs.ReplicationConnection do
end
def on_delete(lsn, table, old_data) do
log(:delete, lsn, table, old_data, nil)
if is_nil(old_data["deleted_at"]) do
log(:delete, lsn, table, old_data, nil)
else
# Avoid overwhelming the change log with soft-deleted records getting hard-deleted en masse.
# Can be removed after https://github.com/firezone/firezone/issues/8187 is shipped.
:ok
end
end
# Relay group tokens don't have account_ids

View File

@@ -140,6 +140,19 @@ defmodule Domain.ChangeLogs.ReplicationConnectionTest do
end
describe "on_delete/2" do
test "ignores soft-deleted records" do
table = "resources"
old_data = %{"id" => Ecto.UUID.generate(), "deleted_at" => "#{DateTime.utc_now()}"}
initial_count = Repo.aggregate(ChangeLog, :count, :id)
assert :ok = on_delete(0, table, old_data)
# No record should be created for soft-deleted records
final_count = Repo.aggregate(ChangeLog, :count, :id)
assert final_count == initial_count
end
test "ignores flows table - no record created" do
table = "flows"
old_data = %{"id" => 1, "name" => "deleted flow"}