Skip to content

Using PostgreSQL UUID as primary key with Doorkeeper OpenID Connect

Kenta Ishizaki edited this page Aug 13, 2026 · 2 revisions

A complete installation guide on UUIDs as primary keys with Doorkeeper can be found at the Doorkeeper wiki.

To enable UUID for OpenID Connect, simply adjust the generated migration:

-    create_table :oauth_openid_requests do |t|
-      t.references :access_grant, null: false, index: true
+    create_table :oauth_openid_requests, id: :uuid do |t|
+      t.references :access_grant, null: false, index: true, type: :uuid
       t.string :nonce, null: false
     end

Leave the generated add_foreign_key(:oauth_openid_requests, :oauth_access_grants, ...) call as-is — the type: :uuid on the reference already makes access_grant_id a UUID column that matches the oauth_access_grants primary key.

Clone this wiki locally