Skip to content

Remove `dependent: :destroy` in models in favor of cascading deletes in the DB

The following discussion from !1114 should be addressed:

  • @shreyasagarwal started a discussion: (+4 comments)

    Can we have specs in the order specs to reflect changes in the order model.

    it { is_expected.to have_many(:license_seat_links).dependent(:destroy) }

    What you think ?

Purpose

According to the GitLab Docs, we should prefer cascading deletes at the DB layer instead of using dependent: :destroy in the application layer. There are a few cases of dependent destroys in the Customers Portal currently that we should remove and replace with cascading deletes.