Upgrade paranoid lib to Ecto 3.x

Hello, long time watcher, first time poster.

I was looking for a lib for soft deletion in ecto and found paranoid: (https://github.com/echobind/paranoid). Unfortunately its only compatible with ecto 2.x, and I’m wanting to put together a PR in to upgrade it to ecto 3.x.

The tests are failing with (UndefinedFunctionError) function Ecto.Query.__schema__/1 is undefined or private and I’ve narrowed it down to these functions on:

The above function is trying to work out whether the field “deleted_at” is present on the schema of the passed in queryable, but I’m not sure how to get a field list for anything other than an ecto schema. Theres a meta key that gets generated for each ecto struct, so I know I can get a field list from there with something like: Map.keys(User.__struct__)

but when it comes to queryables or anything else, I’m stuck.

I’ve also read https://keathley.io/elixir/ecto/2019/01/10/soft-deletion-with-ecto.html, and am beginning to wonder whether this lib might just be too much magic…

I thought if there was an easy answer then I would try to upgrade the lib because it seems like a good fit for what I want, but if not then I’ll probably just try and roll my own


I can’t speak to the particular error you’re hitting, but watch out for some of the changes to how Repo works when manipulating associations. TLDR: overriding things in the repo doesn’t catch the calls that result from passing a cast_assoc changset to Repo.insert anymore.

See https://github.com/ZennerIoT/ex_audit/pull/9 for more discussion.