moxley
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
Sounds good. Thanks @Zach Daniel !
15 replies
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
Or, not doing it in a migration is an option too.
15 replies
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
Doing raw INSERTs would be very difficult, because the record has multiple levels of nested, embedded values. The
return_notifications?: true
option seems like the best route for this.15 replies
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
Okay, got it! I was adding
return_notifications?: true
to the Changeset.for_update()
function. Adding it to API.update()
makes sense.15 replies
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
I would have to redefine several Ash resources into Ecto resources to avoid using Ash
15 replies
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
Most of the logic in the migration is adding records, using Ash resources, and Ash changesets.
15 replies
AEAsh Elixir
•Created by moxley on 8/20/2023 in #support
Notifications warning in migration
I'm calling an Ash action from my ecto migration.
15 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
However, there seems to be the opposite issue when calling
manage_relationship
with type: :append
:
Here, the note doesn't get updated when note_attrs.id
is an integer. The note only updates when it's a string.23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
I modified my action to this:
I cast the string
:id
argument to an integer before calling manage_relationship
.23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
That was it.
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
In the last test I posted, if I change this line,
note_attrs = %{id: to_string(orig_note.id)}
to
note_attrs = %{id: orig_note.id}
,
it passes.23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
Okay, I think this has something to do with with converting between string and integer IDs
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
Calling
manage_relationship
doesn't delete the note either:
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
Here's the action:
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
Here's the test:
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
They both contain this piece of data:
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
I ran an
IO.inspect
at the end of the function above, and it looks exactly like the IO.inspect
I applied when calling manage_relationship
directly.23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
But it still doesn't delete the related record.
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
I also did it to the original code:
23 replies
AEAsh Elixir
•Created by moxley on 7/19/2023 in #support
Using manage_relationship to delete a related record
I set
on_match: {:destroy, :destroy}
.23 replies