Skip to content

Conversation

@mbertrand
Copy link
Member

@mbertrand mbertrand commented Oct 28, 2024

What are the relevant tickets?

N/A

Description (What does it do?)

Fixes a migration failure caused by old unpublished runs with duplicate prices.

How can this be tested?

On the main branch:

  • Run ./manage.py migrate learning_resources 0070_learningresource_location
  • Assign duplicate prices to an existing resource and run:
from learning_resources.models import *
course = LearningResource.objects.filter(resource_type="course").exclude(prices=[]).first()
course.prices = [0, 0, 999]
course.save()
run = course.runs.first()
run.prices = [0, 0, 999]
run.save()
  • Run ./manage.py migrate learning_resources, it will fail due to a duplicate key.
  • Switch to this branch, run the above migration again. It should pass.

Additional Context

ETL pipelines currently ensure that prices for any particular resource and run are unique, but RC and prod have some old unpublished runs still around from before this was implemented, causing a migration error.

@mbertrand mbertrand added the Needs Review An open Pull Request that is ready for review label Oct 28, 2024
@shanbady shanbady self-requested a review October 28, 2024 20:20
@shanbady shanbady self-assigned this Oct 28, 2024
@mbertrand mbertrand changed the title Handle dupe prices during import Handle dupe prices during migration Oct 28, 2024
Copy link
Contributor

@shanbady shanbady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shanbady shanbady added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Oct 28, 2024
@mbertrand mbertrand merged commit a18b93b into main Oct 28, 2024
11 checks passed
@odlbot odlbot mentioned this pull request Oct 28, 2024
33 tasks
@shanbady shanbady deleted the mb/fix_dupe_prices branch October 28, 2024 20:47
@odlbot odlbot mentioned this pull request Oct 29, 2024
34 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants