Invited_by_id` in `insert` does not match type :id (PowInvitation)

Hi everyone, i have a problem with powinvitation library and i wish if some one can help me.
So, i will explain my problem with screenshots:
*) create_user migration file:
image

*) add pow invitation migration file:

*) add organization id for user migration file:
image

*) create organization migration file:

And for the schemas, i have:
*) user schema:

*) organization schema:

but when i run it a got this problem:

I suspect that you are trying to save a string as an uuid. You should try using Ecto.UUID.dump!/1 to cast that value to a binary first. I had the same problem some time ago.

If that’s not the case (if you are using a changeset to cast the values for example), check if you field is actually an uuid/ binary_id as you seem to be trying to persist one.

PS.: Also, if possible, replace the screenshots with markup so the forum search can properly index it. This will make your post more accessible to other people searching for a similar solution.

Update: Seems that your user schema is setting @primary_key as uuid but you are not specifying a @foreign_key_type even though you are referencing the users table by the invited_by_id fk. Could you also check that please?

1 Like

Yeah, I was about to post that they should also make sure @foreign_key_type is properly set.

@yassine There’s also a way to configure these globally in the config/*.exs files for the entire Repo.

Thank you so much guys @dimitarvp @thiagomajesk , yeah it’s work i was in need to add the @foreign_key_type