WIP: Add a model for package #537
No reviewers
Labels
No labels
automation
backend
bug
contributor experience
data
deployment
documentation
duplicate
good first issue
help wanted
nice to have
notifications
package maintainer
performance
skin
tech debt
user story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-community/nix-security-tracker#537
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tweag/florentc/package-schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@ -0,0 +5,4 @@
NixPackage = apps.get_model('shared', 'NixPackage')
NixDerivation = apps.get_model('shared', 'NixDerivation')
with transaction.atomic():
This will probably stop the world for a long time
@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
save
method of the model or use some signal (post_save or other?) or something elseThis would look something like this in both cases:
@ -0,0 +5,4 @@
NixPackage = apps.get_model('shared', 'NixPackage')
NixDerivation = apps.get_model('shared', 'NixDerivation')
with transaction.atomic():
It did take something like 5 min. Do you know how it could be optimized?
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
NixPackage
model have a nullableJSONField
that would store the derivations already together with whatever data we need, channel and version in particular? Then we could populate it on first access (e.g. when it'sNone
and then update whenever a newNixDerivation
is ingested, which would need apost_save
signal onNixDerivation
). At least for now, or maybe we'd do a management command that would populate the cache, just like with suggestions.@ -0,0 +5,4 @@
NixPackage = apps.get_model('shared', 'NixPackage')
NixDerivation = apps.get_model('shared', 'NixDerivation')
with transaction.atomic():
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
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.