We need to make sure merge_requests.source_project_id allows NULL values _before_ updating rows as otherwise this will lead to a NOT NULL constraint failing.
This adds various foreign keys and indexes to the "merge_requests" table as outlined in https://gitlab.com/gitlab-org/gitlab-ce/issues/31825. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/31825