Project

Profile

Help

Task #8203

Fix all migrations to use `apps.get_model(...)` instead of directly importing the model

Added by bmbouter 6 months ago. Updated 6 months ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Estimated time:
Platform Release:
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Description

In various places in the migrations Models are imported directly and then used. This is a hazard for future changes because when the model definition changes this code can break. This happened recently with a change to the AccessPolicy model.

Django in their data migration docs recommend using apps.get_model(...) instead of importing the model directly. This will give you a historical model as of that point in time. We should switch our imports to use that instead.


Related issues

Blocks Pulp - Task #8182: Add an `AccessPolicy.customized` field to tell if a user has customized one or notCLOSED - CURRENTRELEASE

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

Associated revisions

Revision d301f970 View on GitHub
Added by bmbouter 6 months ago

Fixes migration imports to use apps.get_model

In various places in the migrations Models are imported directly and then used. This is a hazard for future changes because when the model definition changes this code can break.

This PR switches data migrations to use apps.get_model(...) intead. It also fixes a syntax migration I noticed on the downmigrate in migration 50.

closes #8203

History

#1 Updated by bmbouter 6 months ago

  • Blocks Task #8182: Add an `AccessPolicy.customized` field to tell if a user has customized one or not added

#2 Updated by pulpbot 6 months ago

  • Status changed from NEW to POST

#3 Updated by bmbouter 6 months ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100

#4 Updated by ttereshc 6 months ago

  • Sprint/Milestone set to 3.10.0

#5 Updated by pulpbot 6 months ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Please register to edit this issue

Also available in: Atom PDF