Compare commits
2
Commits
51ddb42bc7
...
126e26685d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
126e26685d | ||
|
|
45a1203647 |
@@ -36,6 +36,7 @@ class Application < ApplicationRecord
|
|||||||
has_many :allowed_groups, through: :application_groups, source: :group
|
has_many :allowed_groups, through: :application_groups, source: :group
|
||||||
has_many :application_user_claims, dependent: :destroy
|
has_many :application_user_claims, dependent: :destroy
|
||||||
has_many :oidc_authorization_codes, dependent: :destroy
|
has_many :oidc_authorization_codes, dependent: :destroy
|
||||||
|
has_many :oidc_device_codes, dependent: :destroy
|
||||||
has_many :oidc_access_tokens, dependent: :destroy
|
has_many :oidc_access_tokens, dependent: :destroy
|
||||||
has_many :oidc_refresh_tokens, dependent: :destroy
|
has_many :oidc_refresh_tokens, dependent: :destroy
|
||||||
has_many :oidc_user_consents, dependent: :destroy
|
has_many :oidc_user_consents, dependent: :destroy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Clinch
|
module Clinch
|
||||||
VERSION = "0.17.0"
|
VERSION = "0.17.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
class AddCascadeToOidcDeviceCodesApplicationFk < ActiveRecord::Migration[8.1]
|
||||||
|
# Deleting an application left its oidc_device_codes orphaned, tripping this
|
||||||
|
# FK and 500ing the destroy. Mirror application_user_claims: cascade at the DB
|
||||||
|
# level so the delete is safe even if the model-layer cascade is bypassed.
|
||||||
|
def up
|
||||||
|
remove_foreign_key :oidc_device_codes, :applications
|
||||||
|
add_foreign_key :oidc_device_codes, :applications, on_delete: :cascade
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_foreign_key :oidc_device_codes, :applications
|
||||||
|
add_foreign_key :oidc_device_codes, :applications
|
||||||
|
end
|
||||||
|
end
|
||||||
Generated
+2
-2
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.1].define(version: 2026_07_19_000005) do
|
ActiveRecord::Schema[8.1].define(version: 2026_07_19_000006) do
|
||||||
create_table "active_storage_attachments", force: :cascade do |t|
|
create_table "active_storage_attachments", force: :cascade do |t|
|
||||||
t.bigint "blob_id", null: false
|
t.bigint "blob_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@@ -329,7 +329,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_07_19_000005) do
|
|||||||
add_foreign_key "oidc_access_tokens", "users"
|
add_foreign_key "oidc_access_tokens", "users"
|
||||||
add_foreign_key "oidc_authorization_codes", "applications"
|
add_foreign_key "oidc_authorization_codes", "applications"
|
||||||
add_foreign_key "oidc_authorization_codes", "users"
|
add_foreign_key "oidc_authorization_codes", "users"
|
||||||
add_foreign_key "oidc_device_codes", "applications"
|
add_foreign_key "oidc_device_codes", "applications", on_delete: :cascade
|
||||||
add_foreign_key "oidc_device_codes", "users"
|
add_foreign_key "oidc_device_codes", "users"
|
||||||
add_foreign_key "oidc_refresh_tokens", "applications"
|
add_foreign_key "oidc_refresh_tokens", "applications"
|
||||||
add_foreign_key "oidc_refresh_tokens", "oidc_access_tokens"
|
add_foreign_key "oidc_refresh_tokens", "oidc_access_tokens"
|
||||||
|
|||||||
@@ -81,4 +81,14 @@ class ApplicationTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
assert app.valid?, app.errors.full_messages.to_sentence
|
assert app.valid?, app.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "destroying an application with a pending device code succeeds (regression for FK 500)" do
|
||||||
|
app = applications(:kavita_app)
|
||||||
|
device_code = app.oidc_device_codes.create!
|
||||||
|
|
||||||
|
assert_difference("OidcDeviceCode.count", -1) do
|
||||||
|
assert_nothing_raised { app.destroy }
|
||||||
|
end
|
||||||
|
refute OidcDeviceCode.exists?(device_code.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user