-
Notifications
You must be signed in to change notification settings - Fork 644
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
[Prefix] DB changes for Prefix reservation #4394
Conversation
public ReservedPrefix(string pattern, bool isPublicNamespace) | ||
{ | ||
Pattern = pattern; | ||
IsPublicNamespace = isPublicNamespace; |
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 means that the namespace is opened up by the owner to allow everyone to push?
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.
Yes
|
||
[StringLength(CoreConstants.MaxPackageIdLength)] | ||
[Required] | ||
public string Pattern { get; set; } |
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.
We talked about an exact match vs. prefix match. Does this somehow cover both?
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.
Had offline talk with Joel. Changing this to "Value" and adding a new column "IsExactMatch" for cases of "jquery" vs "jquery*" patterns
public virtual ICollection<User> Owners { get; set; } | ||
public virtual ICollection<Package> Packages { get; set; } | ||
public virtual ICollection<ReservedPrefix> ReservedPrefixes { get; set; } |
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.
in what scenario will we need to map PackageRegistration to ReserverPrefixes?
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.
one of the scenario, lets say we want to delete a reserved prefix and it matches an ID, we want to find which other prefixes does this ID match to determine if the "Verified" flag needs to be removed or not? I think it will be useful in the future as well to show all the prefixes an ID matches, in account page may be.
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.
For the account page scenario will not that information come from the User information?
What is the delete flow and what are the delete scenarios?
There are not any tests in this PR.
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.
That would be for users to find which prefixes they own. But for a given package which all prefix it matches would come from this list. Its possible you are a co-owner on a package which matches a prefix owned by someone else so it won't show up in your account page. I am just spitballing here, but you see the point of keeping this mapping of package ids to prefixes, right?
The delete flow would be when a prefix is deleted we want to remove the "verified" tag on a package reservation only if there are no other reserved prefixes matching this package ID owned by one of the owners of this package.
I am planning to add tests with the next PR for adding the admin flow of adding/removing prefixes. That way we will have complete picture. I will look into it and if possible add a few tests in here as well.
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.
How do you map a package to a prefix?
Is Microsoft.Asp.Bla is under Microsoft., Microsoft.Asp., both?
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.
Its under both. When you allocate a reserved prefix to a user, we will check all the packages owned by that user and check if that package matches this reserved prefix. If yes, we add the mapping to it.
{ | ||
public class ReservedPrefix : IEntity | ||
{ | ||
public ReservedPrefix() : this(null, false, false) |
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.
nit: label null and bool params
|
||
public bool IsExactMatch { get; set; } | ||
|
||
public virtual ICollection<PackageRegistration> PackageRegistrations { get; set; } |
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.
I'm concerned about unnecessary joins and loading a lot of not needed info. For example, a prefix can have multiple package registrations. Not every time I load a prefix I need those registrations (that can be in the hundreds). If you write the code that loads ReservedPrefix carefully, this can be avoided. But you should be aware.
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.
Sure, I will keep it in mind and optimize it.
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 looks like these related entities would be lazy loaded when the property is accessed. (See Requirements for Creating POCO Proxies.) If not, please consider enabling lazy loading.
@@ -0,0 +1,68 @@ | |||
namespace NuGetGallery.Migrations | |||
{ |
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.
header
.Index(t => t.User_Key); | ||
|
||
AddColumn("dbo.Users", "Verified", c => c.Boolean(nullable: false)); | ||
AddColumn("dbo.PackageRegistrations", "Verified", c => c.Boolean(nullable: false)); |
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.
Do we need to have "Verified" explicitly on PackageRegistrations table, or perhaps simply finding the registration has a prefix in dbo.PackageRegistrationReservedPrefixes is enough?
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.
I think having it on the PR table is better. We don't need to do additional lookups to determine if a visual indicator is necessary, this makes it easier for auxiliary job too. I would keep it on this table.
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.
You are introducing complexity by forcing two tables to be consistent. For example, when updating a package with a prefix you are going to require a transaction. IMO, it's better to keep it simple, and have the correct indices for a quick join.
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.
Had an offline talk with Svetlana. We are in agreement that it would be beneficial to have this property on PackageRegistrations given that this would be set most cases only once plus not doing this would involve making joins on every query to the package details page(high frequency). Leaving this in.
|
||
public bool IsPublicNamespace { get; set; } | ||
|
||
public bool IsExactMatch { get; set; } |
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.
IsExactMatch is when the 'ReservedPrefix' isn't a prefix? :-)
Maybe the entity should be ReservedNamespace, with column IsPrefix? I would probably also consider renaming IsPublicNamespace to SharedNamespace to indicate that it was shared by the original owner.
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.
Yes that is what it is.
I am fine with those names as well.
public bool EmailAllowed { get; set; } | ||
|
||
public bool Verified { get; set; } |
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.
As mentioned before, I would consider removing User.Verified. I don't think it makes sense on the User. It's really a package state when the package ID matches a reserved namespace, right?
} | ||
|
||
[StringLength(CoreConstants.MaxPackageIdLength)] | ||
[Required] | ||
public string Id { get; set; } | ||
|
||
public int DownloadCount { get; set; } | ||
|
||
public bool Verified { get; set; } |
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.
IsVerified
- done
|
||
public bool IsExactMatch { get; set; } | ||
|
||
public virtual ICollection<PackageRegistration> PackageRegistrations { get; set; } |
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 looks like these related entities would be lazy loaded when the property is accessed. (See Requirements for Creating POCO Proxies.) If not, please consider enabling lazy loading.
Adding tables and relevant columns.