# Postgres Schemas

Masonite ORM supports setting the schema on different classes to change which Postgres schema is called on different actions such as queries and migrations.

> Setting schemas currently only works for the Postgres driver

## Models

On model calls you can set the schema which will pass to the query builder:

```python
User.set_schema("schema2").where(..).get()
```

## Migrations

The migration command will take a `--schema` option to change the schema to run the migrations for. This option is available on all the migration commands.

> If using Masonite you will use the `python craft` command instead of the `masonite-orm` command.

```
$ masonite-orm migrate --schema schema2
```

## Connection Settings

On the postgres connection settings you can set the schema on the `schema` key:

```python
"postgres": {
    "driver": "postgres",
    "host": "...",
    "user": "..",
    "password": "...",
    "schema": "schema2"
},
```

This will set the default schema for the postgres connection


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://orm.masoniteproject.com/other-features/postgres-schema.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
