Skip to content

Remove 'dependent: :destroy' from ProtectedRef has_many :"#{type}_access_levels"

What

Removes dependent: :destroy used in ProtectedRef for has_many :"#{type}_access_levels". This is already overridden in EE so we have some idea how it behaves in production.

Why

Yorick Peterse @yorickpeterse commented in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13693#note_38539801:

@jamedjo The dependent: :destroy should only be used if absolutely necessary, e.g. we need to remove data stored outside of the DB. If possible the removals should be handled by foreign key constraints.

Related

Without foreign keys this would produce the issues seen in https://gitlab.com/gitlab-org/gitlab-ce/issues/36013, but these have been added in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13692

Merge request reports