improvement: don't call .table on nil snapshot

This commit is contained in:
Zach Daniel 2023-04-19 17:32:37 -06:00
parent 86e02d2fe9
commit aec9e1578e

View file

@ -122,11 +122,9 @@ defmodule AshPostgres.MigrationGenerator do
}
end
defp find_references_primary_key(nil, _), do: nil
defp find_references_primary_key(references, snapshots) do
Enum.find_value(snapshots, false, fn snapshot ->
if snapshot.table == references.table do
if snapshot && references && snapshot.table == references.table do
Enum.any?(snapshot.attributes, fn attribute ->
attribute.source == references.destination_attribute
end)