-
Notifications
You must be signed in to change notification settings - Fork 12
Add a model for package #537
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
base: main
Are you sure you want to change the base?
Conversation
| NixPackage = apps.get_model('shared', 'NixPackage') | ||
| NixDerivation = apps.get_model('shared', 'NixDerivation') | ||
|
|
||
| with transaction.atomic(): |
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.
This will probably stop the world for a long time
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 did take something like 5 min. Do you know how it could be optimized?
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.
Generally something like here: https://github.com/Nix-Security-WG/nix-security-tracker/pull/538/files
But see my top level comment for why we may not need that anyway
|
@fricklerhandwerk I wanted your opinion/advice about implementing setting up the package of a derivation automatically and eventually making the package field non nullable. What would be the go-to way to automatically get_or_create a package and assign it to the package field? Should I override the This would look something like this in both cases: package, _ = NixPackage.objects.get_or_create(name=self.attribute)
self.package = package |
|
To be honest, I don't know, but I agree we'd need something like that. Although I wonder whether it's a good idea to store the "package" aggregation at the relational layer. We need that information very quickly for (anything like) search (#215), so it needs to be cached anyway. So why not instead let the |
As a step to implement #532, this WIP PR introduces a db model for packages. For now, a package only has a name. The nix derivation table gains a column, package, for the many-to-one relation from derivation to package. The provided migration ensures the creation of packages associated to all derivations and links each derivation to the right package.
The idea is that user profiles will be in relation with packages to model subscriptions. This will make it possible to subscribe to a package name as we discussed with @fricklerhandwerk and make queries easier to link a "package" and the many derivations. Eventually, we could envision to migrate some metadata from derivations, which are in fact shared and package-related, to this package model.