Convert RepositoryTypeCondition to store SCMTool ID instead of Tool PK.
Review Request #12336 — Created June 3, 2022 and submitted
One of the last places where we were using the old
Tool
model was the
"Repository Type" condition for integration configurations. This used
theBaseConditionModelMultipleChoice
to show a multiple choice field
with the various registered repository types. This meant that the form
field was populated using the contents of the Tool table, and selected
values were stored as the primary keys of the selectedTool
instances.This change makes it so the
RepositoryTypeChoice
instead loads its
values from the new SCMTools registry, using the SCMTool ID as the key.
In order to handle any existing integration configurations, a new stage
has been added to the upgrade to look through existing integration
configurations and update them.
- Created and edited integration configurations using various usage of
the "Repository Type" choice. Saw that everything was loaded from and
saved to the database correctly. - Created several integration configurations using the "Repository Type"
choice and then ran the upgrade. Saw that old lists of integers
(Tool
PKs) were updated to be lists of strings corresponding to the
correct SCMTool IDs. - Ran unit tests.
Summary | ID |
---|---|
988b3c28ef3388f4e00259b2a1a596fb5a10368a |
Description | From | Last Updated |
---|---|---|
Just realized, here and the other data migration change, that scmtool_id can fail if we can't load the SCMTool for … |
chipx86 | |
Two things we can do to optimize this: Skip saving if we don't find a condition to update. Call config.save(update_fields=('settings',)) … |
chipx86 | |
We should make the lookup conditional, since it's completely possible that we'll fail to find a matching value. |
chipx86 | |
line too long (80 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
local variable 'updated_conditions' is assigned to but never used Column: 21 Error code: F841 |
reviewbot |
-
-
Just realized, here and the other data migration change, that
scmtool_id
can fail if we can't load theSCMTool
for any reason (extension not installed, legacy tool, etc.).We should check for this and warn with some sort of instructions. I don't know what that'd look like.
-
Two things we can do to optimize this:
- Skip saving if we don't find a condition to update.
- Call
config.save(update_fields=('settings',))
Also doesn't look like
i
orenumerate
is needed anymore. -
We should make the lookup conditional, since it's completely possible that we'll fail to find a matching value.
- Commits:
-
Summary ID 9419a349b1a3592b963cc930edc79b6dc973e659 3c386549dec7713f8ffe85e984bc4a3c04148372