masonite icon indicating copy to clipboard operation
masonite copied to clipboard

Tenants for postgresql schemas

Open ystekno opened this issue 2 years ago • 4 comments

Is your feature request related to a problem?

Is it possible to connect single database to different schemas in postgresql with different http subfolder like django-tenants?

What do we currently have to do now?

No response

Describe the solution you'd like

For example, there are two tenants named demo and apple: http://localhost:8000//helloworld -> http://localhost:8000/demo/helloworld http://localhost:8000//helloworld -> http://localhost:8000/apple/helloworld

Describe alternatives you've considered

No response

Would this be a breaking change ?

  • [ ] Yes

Anything else ?

No response

ystekno avatar May 23 '22 17:05 ystekno

For the orm part, for now it's not possible to specify the schema for postgres. If it was possible, then you would need to parse the url to find the name of the schema. And then get the query builder instance by passing the schema to it.

girardinsamuel avatar Jun 01 '22 08:06 girardinsamuel

I'll take a look into this issue. It is important to be able to set the tenant at the query level. Even globally so you can modify it on each request (which might need a middleware for that?)

josephmancuso avatar Jun 01 '22 13:06 josephmancuso

This is a great feature

goophps avatar Jun 18 '22 08:06 goophps

@goophps If we add this feature in postgress, then we have to find similar approach for other databases as well and I think it needs some time to be fixed. Till then here's the package implementation: https://github.com/py-package/masonite-multitenancy

yubarajshrestha avatar Sep 21 '22 02:09 yubarajshrestha

This request should use this package https://github.com/py-package/masonite-multitenancy

josephmancuso avatar Oct 09 '22 12:10 josephmancuso