Add sso_audit_logs association and clear logs in demo data cleaner (#638)

- Added `has_many :sso_audit_logs` association to `User` model with `dependent: :nullify`.
- Updated `Demo::DataCleaner` to clear SSO audit logs before destroying related data.

Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
This commit is contained in:
LPW
2026-01-13 11:44:51 -05:00
committed by GitHub
parent ababbb99d0
commit ff55b977d4
2 changed files with 4 additions and 0 deletions

View File

@@ -8,6 +8,9 @@ class Demo::DataCleaner
# Main entry point for destroying all demo data
def destroy_everything!
# Clear SSO audit logs first (they reference users)
SsoAuditLog.destroy_all
Family.destroy_all
Setting.destroy_all
InviteCode.destroy_all

View File

@@ -13,6 +13,7 @@ class User < ApplicationRecord
has_many :impersonator_support_sessions, class_name: "ImpersonationSession", foreign_key: :impersonator_id, dependent: :destroy
has_many :impersonated_support_sessions, class_name: "ImpersonationSession", foreign_key: :impersonated_id, dependent: :destroy
has_many :oidc_identities, dependent: :destroy
has_many :sso_audit_logs, dependent: :nullify
accepts_nested_attributes_for :family, update_only: true
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }