Steve Bussey Blog

Hi everyone,

I’m going to use this thread to aggregate any new blog posts.

The one I just released is about using Ecto.Repo’s prepare_query callback function to ensure that all queries in an Elixir application have tenancy set properly. You can find it at https://stephenbussey.com/2019/12/30/verifying-queries-with-ecto-s-prepare_query.html.

9 Likes

I saw the title and went “No! I tried that, that didn’t work.”

Turns out you are doing tenancy slightly differently than I have. Did you look at this? Multi tenancy with query prefixes

I thought you approach would be to change the prefix value with prepare_query which did not work me. But catching whether its set and raising if it is about to the do the wrong thing would be a good addition to what I’m doing. I’ll add a reference to this in my post on multi-tenancy through prefixes.

Thanks for the idea :slight_smile:

2 Likes

I have heard of this technique but I’ve never personally used it. To be honest, a lot of my multi tenant theory comes from how CitusDB does it, since implementing that really forced us to have everything explicitly tenanted out. Even join tables which we thought maybe didn’t need tenant information on them.

The nice thing here is that there are options, since one size doesn’t fit all. Thanks for sharing.

2 Likes