chore: rewrite keys properly

This commit is contained in:
Zach Daniel 2022-08-18 16:11:47 -04:00
parent 4a69edce2d
commit a563786218

View file

@ -2303,6 +2303,11 @@ defmodule AshPostgres.MigrationGenerator do
references ->
references
|> rewrite(
destination_field: :destination_attribute,
destination_field_default: :destination_attribute_default,
destination_field_generated: :destination_attribute_generated
)
|> Map.delete(:ignore)
|> rewrite(:ignore?, :ignore)
|> Map.update!(:destination_attribute, &String.to_atom/1)
@ -2327,6 +2332,12 @@ defmodule AshPostgres.MigrationGenerator do
end)
end
defp rewrite(map, keys) do
Enum.reduce(map, fn {key, to} ->
rewrite(map, key, to)
end)
end
defp rewrite(map, key, to) do
if Map.has_key?(map, key) do
map