> For the complete documentation index, see [llms.txt](https://doorkeeper.gitbook.io/guides/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doorkeeper.gitbook.io/guides/internals/database-design.md).

# Database Design

## oauth\_applications

| Field             | Purpose                                                                                              |
| ----------------- | ---------------------------------------------------------------------------------------------------- |
| **id**            | Primary key, in case of using RDBMs                                                                  |
| **name**          | Application name                                                                                     |
| **uid**           | Unique ID, used as [*client identifier*](https://tools.ietf.org/html/rfc6749#section-2.2)            |
| **secret**        | Used together with `uid` for client authentication                                                   |
| **redirect\_uri** | Redirects the resource owner to this URI ([spec](https://tools.ietf.org/html/rfc6749#section-3.1.2)) |
| **scopes**        | Defines which [scopes](/guides/configuration/scopes.md) the application uses                         |
| **confidential**  | Indicates whether client public or private                                                           |
| **created\_at**   | Creation date & time                                                                                 |
| **updated\_at**   | Date & time of latest update                                                                         |

If you set `enable_application_owner` configuration option then applications table also includes:

| Field           | Purpose                         |
| --------------- | ------------------------------- |
| **owner\_id**   | PK of the Resource owner record |
| **owner\_type** | Resource owner model name       |

## oauth\_access\_tokens

| Field                        | Purpose                                       |
| ---------------------------- | --------------------------------------------- |
| **id**                       | Primary key, in case of using RDBMs           |
| **resource\_owner\_id**      | PK of the resource owner record               |
| **application\_id**          | PK of the client token was issued for         |
| **token**                    | Token value                                   |
| **refresh\_token**           | Refresh token value (used to refresh a token) |
| **expires\_in**              | TTL of the token (in seconds)                 |
| **revoked\_at**              | Date & time when token was revoked            |
| **created\_at**              | Creation date & time                          |
| **scopes**                   | Access token scopes                           |
| **previous\_refresh\_token** | Previous refresh token value                  |

If you enabled `use_polymorphic_resource_owner` configuration option then your database must have additional columns:

| Field                     | Purpose                   |
| ------------------------- | ------------------------- |
| **resource\_owner\_type** | Resource owner model name |

## oauth\_access\_grants

| Field                   | Purpose                               |
| ----------------------- | ------------------------------------- |
| **id**                  | Primary key, in case of using RDBMs   |
| **resource\_owner\_id** | PK of the resource owner record       |
| **application\_id**     | PK of the client token was issued for |
| **token**               | Token value                           |
| **expires\_in**         | TTL of the token (in seconds)         |
| **redirect\_uri**       | Redirect URI                          |
| **revoked\_at**         | Date & time when token was revoked    |
| **created\_at**         | Creation date & time                  |
| **scopes**              | Access token scopes                   |

In case you enabled PKCE flow, your access grants table will include:

| Field                       | Purpose                    |
| --------------------------- | -------------------------- |
| **code\_challenge**         | Code challenge value       |
| **code\_challenge\_method** | Code challenge method name |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://doorkeeper.gitbook.io/guides/internals/database-design.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
