• Stan Hu's avatar
    Add missing cascading deletes on foreign keys for group_id · b6e6d0b3
    Stan Hu authored
    It was possible to grant access to a group to do things to protected
    branches or tags, but if the group were deleted, the deletion
    might fail due to a message such as the following:
    
    ```
    ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR:  update or delete on table "namespaces" violates foreign key constraint "fk_rails_7111b68cdb" on table "protected_branch_push_access_levels"
    DETAIL:  Key (id)=(1827859) is still referenced from table "protected_branch_push_access_levels".
    : DELETE FROM "namespaces" WHERE "namespaces"."type" IN ('Group') AND "namespaces"."id" = 1827859
    ```
    
    This MR fixes this by adding missing cascading deletions to the
    group_id foreign keys in the following tables:
    
    * protected_branch_merge_access_levels
    * protected_branch_push_access_levels
    * protected_tag_create_access_levels
    
    Closes #3343, #3344, gitlab-org/gitlab-ce#37311
    b6e6d0b3
schema.rb 98.9 KB