-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix migration failure #1737
Fix migration failure #1737
Conversation
No, we need to reopen this. I also encountered the null-constraint error @alukach ran into as mentioned in #1716 but I thought it was just me. Now that Anthony has explained the issue, the migration error makes perfect sense. This is a totally separate issue from the null-area locations bug. The issue is that the 0006 migration fails if the project has no locations at all. So it does not matter if location areas default to |
Ok, this will need to be changed to migration 0007 as there's already a 0006 in master. |
@amplifi This is a bugfix to the 0006 migration, it is not a new migration. This bug causes organizations/0006 fails, so any subsequent migrations will not run (assuming the conditions described in #1716 (comment) are met). |
If this is a bugfix, it's required to include tests to prevent regression. |
@amplifi Sure, I've updated the previously written test. |
@@ -30,6 +30,7 @@ def test_migration(self): | |||
call_command('migrate', 'organization', self.migrate_from) | |||
|
|||
org = Organization.objects.create(name='Test Org') | |||
Project.objects.create(name='No Locations Proj', organization=org) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the unit test failed because you need to specify unique id
s for both projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks. I just made the commit and closed my laptop. Will correct it tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use the existing ProjectFactory
for cases like this.
@seav Do the latest changes satisfy your review? If so, please update to approved. This is blocking for the staging release build. |
Fix bug where migration fails if no spatial units are associated with project.
70a6f1b
to
b073750
Compare
Fix bug where migration fails if no spatial units are associated with project.
As mentioned in #1716.
Proposed changes in this pull request
Use
COALESCE
to fallback to0
ifsum(<spatial_unit_areas>) == null
, in the event that a Project has no associated SpatialUnit instances.When should this PR be merged
Before releasing #1716.
Risks
[List any risks that could arise from merging your pull request.]
Follow-up actions
[List any possible follow-up actions here; for instance, testing data
migrations, software that we need to install on staging and production
environments.]
Checklist (for reviewing)
General
migration
label if a new migration is added.Functionality
Code
Tests
Security
Documentation