Issue #8329

Updated by ggainey over 3 years ago

Pulp2Content model has a FK to Pulp2Repository as a part of the uniqueness constraint on the model.   
 The FK can be null, because it is set only for content types which depend on a repo and can be associated only with one of them. 
 Since each null is unique, it creates duplicated entries, if something changed about this content in pulp2. 

 ### To reproduce 

  - migrate pulp2 rpm on_demand content 
  - download that content in pulp2 
  - run migration again 

 ### Solution 

  - Remove FK from the uniqueness constraint 
  - FOR ERRATA ONLY: set pulp2_subuid to a repo_id value where an FK to a repo has been set 
   - this will maintain the necessary uniqueness for errata 
   - subuid is currently only used by deb-migration 
  - data migration is needed 
   - find the dups; keep the one with the most-recent pulp2_last_updated, delete the others 
   - for all    pulp2_content_type_id=errata in pulp_2to3_migration_pulp2content, set pulp2_subid = pulp2_repo_id