Multi-tenant domain setup, PostgreSQL

Zapotocny
Member | 16
+
0
-

Hello,

is there any simple way of setting PostreSQL database schema on startup of whole application?

I would use difference database schemas for each tenant.

abc.domain.com → would look inside public schema inside table tenants,

it would find “schema_name” column where domain_url = abc.domain.com,
then it would set database cursor to that schema.

I want to have almost same functionality as this Django package https://github.com/…nant-schemas

Thank you so much, all tips are valuable.

CZechBoY
Member | 3608
+
0
-

What database library do you use?
but in general it would be same – listen on event Connect and then choose correct schema

Zapotocny
Member | 16
+
0
-

CZechBoY wrote:

What database library do you use?
but in general it would be same – listen on event Connect and then choose correct schema

I would like to use Doctrine, so https://github.com/Kdyby/Doctrine

Ondřej Kubíček
Member | 494
+
0
-

@Zapotocny off speech, you wanna use nettrine/doctrine because kdyby is no longer being developed :)

Zapotocny
Member | 16
+
0
-

Ondřej Kubíček wrote:

@Zapotocny off speech, you wanna use nettrine/doctrine because kdyby is no longer being developed :)

Ok, i will look at it. @OndřejKubíček do you have any idea how to implement that tenant behaviour?