Skip to content

Commit 2c31b3e

Browse files
committed
fix: don't assume old snapshots have index? key for attributes
1 parent f077958 commit 2c31b3e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/migration_generator/migration_generator.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ defmodule AshPostgres.MigrationGenerator do
17591759

17601760
reference_indexes_to_add =
17611761
Enum.filter(snapshot.attributes, fn attribute ->
1762-
if attribute.references, do: attribute.references.index?
1762+
if attribute.references, do: attribute.references[:index?]
17631763
end)
17641764
|> Enum.map(fn attribute ->
17651765
%Operation.AddReferenceIndex{
@@ -1777,10 +1777,10 @@ defmodule AshPostgres.MigrationGenerator do
17771777
attribute.source == old_attribute.source
17781778
end)
17791779

1780-
has_removed_index? = attribute && not attribute.index? && old_attribute.index?
1781-
attribute_doesnt_exist? = !attribute && old_attribute.index?
1780+
has_removed_index? = attribute && !attribute[:index?] && old_attribute[:index?]
1781+
attribute_doesnt_exist? = !attribute && old_attribute[:index?]
17821782

1783-
has_removed_index? or attribute_doesnt_exist?
1783+
has_removed_index? || attribute_doesnt_exist?
17841784
end)
17851785
|> Enum.map(fn attribute ->
17861786
%Operation.RemoveReferenceIndex{

0 commit comments

Comments
 (0)