MasoniteFramework / masonite

The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Discord channel for questions: https://discord.gg/TwKeFahmPZ
http://docs.masoniteproject.com
MIT License
2.22k stars 126 forks source link

Tenants for postgresql schemas #642

Closed ystekno closed 2 years ago

ystekno commented 2 years ago

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 ?

Anything else ?

No response

girardinsamuel commented 2 years ago

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.

josephmancuso commented 2 years ago

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?)

goophps commented 2 years ago

This is a great feature

yubarajshrestha commented 2 years ago

@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

josephmancuso commented 2 years ago

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