# Multi tenant setup

**URL:** <https://discourse.getdbt.com/t/multi-tenant-setup/3378>\
**Category:** Archive\
**Created:** [November 17, 2021, 2:14pm UTC](https://discourse.getdbt.com/t/multi-tenant-setup/3378 "2021-11-17T14:14:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tafkas](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/tafkas/32/909_2.png) [@Tafkas](https://discourse.getdbt.com/u/Tafkas)\
**Post date:** [November 17, 2021, 2:14pm UTC](https://discourse.getdbt.com/t/multi-tenant-setup/3378/1 "2021-11-17T14:14:21Z")

</div>

I have a database where for each customer there is one specific schema. All the schemas share the same layout.

customer\_1.orders  
customer\_2.orders  
.  
.  
.  
customer\_n.orders

I am trying to have a small etl process using dbt to create the following. I want a transformed orders\_fact table in each of these schemas.

customer\_1.orders\_fact  
customer\_2.orders\_fact  
.  
.  
.  
customer\_n.orders\_fact

On top each schema has a unique user/password combination to access the data (e.g. schema customer\_1 has username: user\_1, password: random\_password).

How would I set this up in dbt. I am currently struggling with the unique name constraint of a model and how to set up the config in a way that for each schema there are specific credentials.

---

<div class="post-metadata">

**Author:** ![meurant.naude](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/meurant.naude/32/506_2.png) [@meurant.naude](https://discourse.getdbt.com/u/meurant.naude)\
**Post date:** [November 17, 2021, 10:32pm UTC](https://discourse.getdbt.com/t/multi-tenant-setup/3378/2 "2021-11-17T22:32:07Z")

</div>

Hi there,  
You may want to consider creating “dynamic” models which, in a nutshell, means this:

- Have code for generic model `customer.orders`
- Schema, table and database are all variables in the config block
- When you execute `dbt run`, provide values for variables as per normal
- You could also have a macro called from the generic model with a `FOR` loop to go through the list of variable values
- Have a macro to give access can be given based on variable values

Hope this makes sense.

---

<div class="post-metadata">

**Author:** ![dbtheadache](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@dbtheadache](https://discourse.getdbt.com/u/dbtheadache)\
**Post date:** [May 12, 2022, 6:58am UTC](https://discourse.getdbt.com/t/multi-tenant-setup/3378/3 "2022-05-12T06:58:01Z")

</div>

Hi, I’m running into the same problem as you. Would you mind sharing what you have explored? @Tafkas
