# Plug multiple schemas

{% hint style="warning" %}
Please be sure of your agent type and version and pick the right documentation accordingly.
{% endhint %}

{% tabs %}
{% tab title="Node.js" %}
{% hint style="danger" %}
This is the documentation of the `forest-express-sequelize` and `forest-express-mongoose` Node.js agents that will soon reach end-of-support.

`forest-express-sequelize` v9 and `forest-express-mongoose` v9 are replaced by [`@forestadmin/agent`](https://docs.forestadmin.com/developer-guide-agents-nodejs/) v1.

Please check your agent type and version and read on or switch to the right documentation.
{% endhint %}
{% endtab %}

{% tab title="Ruby on Rails" %}
{% hint style="success" %}
This is still the latest Ruby on Rails documentation of the `forest_liana` agent, you’re at the right place, please read on.
{% endhint %}
{% endtab %}

{% tab title="Python" %}
{% hint style="danger" %}
This is the documentation of the `django-forestadmin` Django agent that will soon reach end-of-support.

If you’re using a Django agent, notice that `django-forestadmin` v1 is replaced by [`forestadmin-agent-django`](https://docs.forestadmin.com/developer-guide-agents-python) v1.

If you’re using a Flask agent, go to the [`forestadmin-agent-flask`](https://docs.forestadmin.com/developer-guide-agents-python) v1 documentation.

Please check your agent type and version and read on or switch to the right documentation.
{% endhint %}
{% endtab %}

{% tab title="PHP" %}
{% hint style="danger" %}
This is the documentation of the `forestadmin/laravel-forestadmin` Laravel agent that will soon reach end-of-support.

If you’re using a Laravel agent, notice that `forestadmin/laravel-forestadmin` v1 is replaced by [`forestadmin/laravel-forestadmin`](https://docs.forestadmin.com/developer-guide-agents-php) v3.

If you’re using a Symfony agent, go to the [`forestadmin/symfony-forestadmin`](https://docs.forestadmin.com/developer-guide-agents-php) v1 documentation.

Please check your agent type and version and read on or switch to the right documentation.
{% endhint %}
{% endtab %}
{% endtabs %}

## Plug multiple schemas

A **schema** is an organizational layer to better structure your SQL database.

At installation, you may only choose 1 schema:

![](https://2014605362-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR7SWfEwsNtj_ZiSkSA%2F-M0ITatq6hZaue8ucs-E%2F-M0Im4Ul4QDjuylHJ_Co%2FCapture%20d%E2%80%99e%CC%81cran%202020-02-17%20a%CC%80%2016.27.45.png?alt=media\&token=54ced38a-58a7-4af1-87ec-9d2841652fe0)

{% hint style="info" %}
If you're not using specific schemas, you don't have to fill this advanced option.
{% endhint %}

#### Forest Admin can display collections from multiple schemas

To achieve this, proceed to install using 1 of your schemas. Only the models of this schema will be generated in your `models` directory.

Let's take a model example:

{% code title="models/addresses.js" %}

```javascript
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v5/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v5/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const Addresses = sequelize.define(
    'addresses',
    {
      addressLine: {
        type: DataTypes.STRING,
        field: 'address',
      },
      addressCity: {
        type: DataTypes.STRING,
      },
      country: {
        type: DataTypes.STRING,
      },
      createdAt: {
        type: DataTypes.DATE,
      },
    },
    {
      tableName: 'addresses',
      underscored: true,
      schema: process.env.DATABASE_SCHEMA,
    }
  );

  return Addresses;
};
```

{% endcode %}

On **line 24**, you'll notice `schema: process.env.DATABASE_SCHEMA`.

It uses the environment variable `DATABASE_SCHEMA` set in your **.env** file.\
You'll have to edit this to match your schemas. For instance, if you have 2 schemas:

{% code title=".env" %}

```javascript
DATABASE_SCHEMA_1: name_of_the_first_schema;
DATABASE_SCHEMA_2: name_of_the_second_schema;
```

{% endcode %}

Once this is done, follow those steps:

**Step 1: Edit your current models**

Because you have changed your environment variable name from `DATABASE_SCHEMA` to `DATABASE_SCHEMA_1`, you need to update it in all your models' file in the `models` directory (same line as line 24 in the above example).

**Step 2: Create new models**

For each of your other schemas' models, you'll need to create a file in `models`. This must be done **manually** and the schema line must be set to `DATABASE_SCHEMA_2` as per above example.

{% hint style="info" %}
If your other schemas have a lot of models, a quick way to generate the models is to create a another project using those other schemas (1 project for each schema).
{% endhint %}
