mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
fix(portal): don't log soft-deleted deletes (#9698)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user