Skip to content
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

Part responsible owner #5774

Merged

Conversation

SchrodingersGat
Copy link
Member

- Will replace "responsible" field
- Adds 'responsible_owner' value for parts which have 'responsible' set
- Selects correct content type
- Performs reverse migratoin
- Point to the new field
- Rename to preserve compatibility
- OPTIONS metadata will take care of the rest
@SchrodingersGat SchrodingersGat added the part Related to Part models label Oct 23, 2023
@SchrodingersGat SchrodingersGat added this to the 0.13.0 milestone Oct 23, 2023
@netlify
Copy link

netlify bot commented Oct 23, 2023

Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit e2ce187
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/653646f90fa4a90008d4a58d

Copy link
Contributor

@matmair matmair left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines 699 to 703
responsible = serializers.PrimaryKeyRelatedField(
queryset=users.models.Owner.objects.all(),
source='responsible_owner',
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment: This should lead to a bumb of the API version, right?

@SchrodingersGat
Copy link
Member Author

@miggland FYI this is how complex migrations should be handled. In separate sequential migrations:

  1. Add the new field to the model
  2. Perform custom data migration
  3. Delete the old field

Data and schema migrations should not be performed in the same step. And it should be written in such a way that it is reversible if required :)

@SchrodingersGat SchrodingersGat merged commit 39c4996 into inventree:master Oct 23, 2023
24 checks passed
@SchrodingersGat SchrodingersGat deleted the part-responsible-owner branch October 23, 2023 10:35
@miggland
Copy link
Contributor

Looks nice, thanks for fixing this. 👍

@SchrodingersGat
Copy link
Member Author

No worries, it is a pretty tricky thing to get right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part Related to Part models
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Part responsible is limited to a User, groups not allowed
3 participants