Project

Profile

Help

Task #8203

closed

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

Added by bmbouter almost 4 years ago. Updated almost 4 years 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 - CURRENTRELEASEbmbouter

Actions
Actions #1

Updated by bmbouter almost 4 years ago

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

Updated by pulpbot almost 4 years ago

  • Status changed from NEW to POST

Added by bmbouter almost 4 years ago

Revision d301f970 | View on GitHub

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

Actions #3

Updated by bmbouter almost 4 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100
Actions #4

Updated by ttereshc almost 4 years ago

  • Sprint/Milestone set to 3.10.0
Actions #5

Updated by pulpbot almost 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF