> 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/configuration/models.md).

# Models

Starting from Doorkeeper 5.3 you can use your own model classes if you need to extend (or even override) default Doorkeeper models such as `Application`, `AccessToken` and `AccessGrant`.

By default Doorkeeper ActiveRecord ORM uses it's own classes:

```ruby
# app/initializers/doorkeeper.rb

Doorkeeper.configure do 
  access_token_class "Doorkeeper::AccessToken"
  access_grant_class "Doorkeeper::AccessGrant"
  application_class "Doorkeeper::Application"
end
```

If you're planning to use your own, don't forget inherit them from the base classes (listed above) or at least to **include** Doorkeeper ORM mixins into your custom models first:

* `::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken` - for access token
* `::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant` - for access grant
* `::Doorkeeper::Orm::ActiveRecord::Mixins::Application` - for application (OAuth2 client)

An example of model customization:

```ruby
Doorkeeper.configure do
  access_token_class "MyAccessToken"
  # ...
end

# app/models/my_access_token.rb
class MyAccessToken < ApplicationRecord
  include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken

  self.table_name = "hey_i_wanna_my_name"

  def destroy_me!
    destroy
  end
end
```


---

# 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/configuration/models.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.
