Merge pull request #7906 from tchak/fix-user-destroy-dossiers

fix(dossier): we should never detroy user’s dossiers in cascade
This commit is contained in:
Paul Chavard 2022-10-14 14:21:46 +02:00 committed by GitHub
commit b4cec14d6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,7 +41,10 @@ class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :lockable
has_many :dossiers, dependent: :destroy
# We should never cascade delete dossiers. In normal case we call delete_and_keep_track_dossiers
# before deleting a user (which dissociate dossiers from the user).
# Destroying a user with dossier is always a mistake.
has_many :dossiers, dependent: :restrict_with_exception
has_many :targeted_user_links, dependent: :destroy
has_many :invites, dependent: :destroy
has_many :dossiers_invites, through: :invites, source: :dossier