Skip to content

Validate exactly one of organization, group and project is present in BulkImport::Entity

The following discussion from !172262 (merged) should be addressed:

  • @krasio started a discussion: (+2 comments)

    Since the back-fill is done in a post-deployment migration, this will be deployed first and there could be hours or even days between. Until back-fill is completed records that need it will be failing validation (on update) because of this. How big of a problem is this going to be?

There is a validation in in BulkImport::Entity which checks that only 1 of project, group, or organization exists. This check currently only happens on create, because when it was first added, we could not be sure that the migration to update existing records with an organization had finished running yet. We should change this to happen in all cases and remove the other 2 validations for project/group being absent if the other is present.

Implementation

In app/models/bulk_imports/entity.rb we have a validation validate_only_one_sharding_key_present, which only runs on create. This should be changed to always run.

Additionally, we have 2 validations to ensure that the project is absent if the group is present, and another that the group is absent if the project is present. As these checks are covered by the validate_only_one_sharding_key_present validation, these 2 can be removed.

Edited by Keeyan Nejad