From b0aa51e8114d6465b648aa819478c10ad86d9dff Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 20 May 2026 17:47:26 +0530 Subject: [PATCH] chore: update migration --- app/models/access_token.rb | 1 + db/migrate/20260520073722_add_scope_to_access_tokens.rb | 3 +++ db/schema.rb | 1 + 3 files changed, 5 insertions(+) diff --git a/app/models/access_token.rb b/app/models/access_token.rb index de3804b68..951f44e30 100644 --- a/app/models/access_token.rb +++ b/app/models/access_token.rb @@ -12,6 +12,7 @@ # # Indexes # +# index_access_tokens_on_owner_and_scope (owner_type,owner_id,scope) UNIQUE # index_access_tokens_on_owner_type_and_owner_id (owner_type,owner_id) # index_access_tokens_on_token (token) UNIQUE # diff --git a/db/migrate/20260520073722_add_scope_to_access_tokens.rb b/db/migrate/20260520073722_add_scope_to_access_tokens.rb index 809dcf40b..4f70ef80b 100644 --- a/db/migrate/20260520073722_add_scope_to_access_tokens.rb +++ b/db/migrate/20260520073722_add_scope_to_access_tokens.rb @@ -1,5 +1,8 @@ class AddScopeToAccessTokens < ActiveRecord::Migration[7.1] def change add_column :access_tokens, :scope, :string, default: 'full', null: false + add_index :access_tokens, [:owner_type, :owner_id, :scope], + unique: true, + name: 'index_access_tokens_on_owner_and_scope' end end diff --git a/db/schema.rb b/db/schema.rb index 11a4d22d2..b365b860e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -25,6 +25,7 @@ ActiveRecord::Schema[7.1].define(version: 2026_05_20_073722) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "scope", default: "full", null: false + t.index ["owner_type", "owner_id", "scope"], name: "index_access_tokens_on_owner_and_scope", unique: true t.index ["owner_type", "owner_id"], name: "index_access_tokens_on_owner_type_and_owner_id" t.index ["token"], name: "index_access_tokens_on_token", unique: true end