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.
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.