Multi tenancy in phoenix

I have a rails app that uses postgres with multi tenancy using apartment.
I would like to receive write some parts of the json api using phoenix. This is primarily for a learning excercises but also to look at performance gains.

Can anyone please help in how I switch to a different tenant (postgres schema) on a per request basis ?

Thanks

Gary

2 Likes

Perhaps this might help? https://github.com/Dania02525/apartmentex

Sam

1 Like

Hi Gary,

Because Ecto already has a concept of Schema, which refers to something completely different from postgres schemas, they refer to this feature as a Prefix. Take a look at the section called Query Prefix in the docs here.

1 Like

Hi Sam,
Thanks for this. I have tried this but had compilation issues so gave up with it, but I will try again and persevere a bit more. Im totally new to exlixir - Im a ruby def primarily so everything is new :slight_smile:

Thanks for the suggestion

Gary

1 Like

Thanks jlevy - I will look into this

Gary

1 Like