Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
shishirx34 committed Jul 19, 2017
1 parent 4d2326f commit 4aeac85
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 51 deletions.
6 changes: 3 additions & 3 deletions src/NuGetGallery.Core/Entities/PackageRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public PackageRegistration()
{
Owners = new HashSet<User>();
Packages = new HashSet<Package>();
ReservedPrefixes = new HashSet<ReservedPrefix>();
ReservedNamespaces = new HashSet<ReservedNamespace>();
}

[StringLength(CoreConstants.MaxPackageIdLength)]
Expand All @@ -22,11 +22,11 @@ public PackageRegistration()

public int DownloadCount { get; set; }

public bool Verified { get; set; }
public bool IsVerified { get; set; }

public virtual ICollection<User> Owners { get; set; }
public virtual ICollection<Package> Packages { get; set; }
public virtual ICollection<ReservedPrefix> ReservedPrefixes { get; set; }
public virtual ICollection<ReservedNamespace> ReservedNamespaces { get; set; }

public int Key { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@

namespace NuGetGallery
{
public class ReservedPrefix : IEntity
public class ReservedNamespace : IEntity
{
public ReservedPrefix()
: this(value: null, isPublicNamespace: false, isExactMatch: false)
public ReservedNamespace()
: this(value: null, isSharedNamespace: false, isExactMatch: false)
{
}

public ReservedPrefix(string value, bool isPublicNamespace, bool isExactMatch)
public ReservedNamespace(string value, bool isSharedNamespace, bool isExactMatch)
{
Value = value;
IsPublicNamespace = isPublicNamespace;
IsExactMatch = isExactMatch;
IsSharedNamespace = isSharedNamespace;
IsPrefix = isExactMatch;
PackageRegistrations = new HashSet<PackageRegistration>();
ReservedPrefixOwners = new HashSet<User>();
ReservedNamespaceOwners = new HashSet<User>();
}

[StringLength(CoreConstants.MaxPackageIdLength)]
[Required]
public string Value { get; set; }

public bool IsPublicNamespace { get; set; }
public bool IsSharedNamespace { get; set; }

public bool IsExactMatch { get; set; }
public bool IsPrefix { get; set; }

public virtual ICollection<PackageRegistration> PackageRegistrations { get; set; }
public virtual ICollection<User> ReservedPrefixOwners { get; set; }
public virtual ICollection<User> ReservedNamespaceOwners { get; set; }

[Key]
public int Key { get; set; }
Expand Down
6 changes: 2 additions & 4 deletions src/NuGetGallery.Core/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public User(string username)
{
Credentials = new List<Credential>();
SecurityPolicies = new List<UserSecurityPolicy>();
ReservedPrefixes = new HashSet<ReservedPrefix>();
ReservedNamespaces = new HashSet<ReservedNamespace>();
Roles = new List<Role>();
Username = username;
}
Expand All @@ -40,9 +40,7 @@ public User(string username)

public bool EmailAllowed { get; set; }

public bool Verified { get; set; }

public virtual ICollection<ReservedPrefix> ReservedPrefixes { get; set; }
public virtual ICollection<ReservedNamespace> ReservedNamespaces { get; set; }

[DefaultValue(true)]
public bool NotifyPackagePushed { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery.Core/NuGetGallery.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<Compile Include="Entities\PackageLicense.cs" />
<Compile Include="Entities\PackageLicenseReport.cs" />
<Compile Include="Entities\PackageOwnerRequest.cs" />
<Compile Include="Entities\ReservedPrefix.cs" />
<Compile Include="Entities\ReservedNamespace.cs" />
<Compile Include="Entities\PackageRegistration.cs" />
<Compile Include="Entities\PackageType.cs" />
<Compile Include="Entities\ReadOnlyModeException.cs" />
Expand Down
59 changes: 27 additions & 32 deletions src/NuGetGallery/Migrations/201707131923337_PrefixReservation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace NuGetGallery.Migrations
{
using System;
Expand All @@ -11,61 +8,59 @@ public partial class PrefixReservation : DbMigration
public override void Up()
{
CreateTable(
"dbo.ReservedPrefixes",
"dbo.ReservedNamespaces",
c => new
{
Key = c.Int(nullable: false, identity: true),
Value = c.String(nullable: false, maxLength: 128),
IsPublicNamespace = c.Boolean(nullable: false),
IsExactMatch = c.Boolean(nullable: false)
IsSharedNamespace = c.Boolean(nullable: false),
IsPrefix = c.Boolean(nullable: false),
})
.PrimaryKey(t => t.Key);

CreateTable(
"dbo.PackageRegistrationReservedPrefixes",
"dbo.PackageRegistrationReservedNamespaces",
c => new
{
PackageRegistration_Key = c.Int(nullable: false),
ReservedPrefix_Key = c.Int(nullable: false),
ReservedNamespace_Key = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.PackageRegistration_Key, t.ReservedPrefix_Key })
.PrimaryKey(t => new { t.PackageRegistration_Key, t.ReservedNamespace_Key })
.ForeignKey("dbo.PackageRegistrations", t => t.PackageRegistration_Key, cascadeDelete: true)
.ForeignKey("dbo.ReservedPrefixes", t => t.ReservedPrefix_Key, cascadeDelete: true)
.ForeignKey("dbo.ReservedNamespaces", t => t.ReservedNamespace_Key, cascadeDelete: true)
.Index(t => t.PackageRegistration_Key)
.Index(t => t.ReservedPrefix_Key);
.Index(t => t.ReservedNamespace_Key);

CreateTable(
"dbo.ReservedPrefixUsers",
"dbo.ReservedNamespaceUsers",
c => new
{
ReservedPrefix_Key = c.Int(nullable: false),
ReservedNamespace_Key = c.Int(nullable: false),
User_Key = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.ReservedPrefix_Key, t.User_Key })
.ForeignKey("dbo.ReservedPrefixes", t => t.ReservedPrefix_Key, cascadeDelete: true)
.PrimaryKey(t => new { t.ReservedNamespace_Key, t.User_Key })
.ForeignKey("dbo.ReservedNamespaces", t => t.ReservedNamespace_Key, cascadeDelete: true)
.ForeignKey("dbo.Users", t => t.User_Key, cascadeDelete: true)
.Index(t => t.ReservedPrefix_Key)
.Index(t => t.ReservedNamespace_Key)
.Index(t => t.User_Key);

AddColumn("dbo.Users", "Verified", c => c.Boolean(nullable: false));
AddColumn("dbo.PackageRegistrations", "Verified", c => c.Boolean(nullable: false));
AddColumn("dbo.PackageRegistrations", "IsVerified", c => c.Boolean(nullable: false));
}

public override void Down()
{
DropForeignKey("dbo.ReservedPrefixUsers", "User_Key", "dbo.Users");
DropForeignKey("dbo.ReservedPrefixUsers", "ReservedPrefix_Key", "dbo.ReservedPrefixes");
DropForeignKey("dbo.PackageRegistrationReservedPrefixes", "ReservedPrefix_Key", "dbo.ReservedPrefixes");
DropForeignKey("dbo.PackageRegistrationReservedPrefixes", "PackageRegistration_Key", "dbo.PackageRegistrations");
DropIndex("dbo.ReservedPrefixUsers", new[] { "User_Key" });
DropIndex("dbo.ReservedPrefixUsers", new[] { "ReservedPrefix_Key" });
DropIndex("dbo.PackageRegistrationReservedPrefixes", new[] { "ReservedPrefix_Key" });
DropIndex("dbo.PackageRegistrationReservedPrefixes", new[] { "PackageRegistration_Key" });
DropColumn("dbo.PackageRegistrations", "Verified");
DropColumn("dbo.Users", "Verified");
DropTable("dbo.ReservedPrefixUsers");
DropTable("dbo.PackageRegistrationReservedPrefixes");
DropTable("dbo.ReservedPrefixes");
DropForeignKey("dbo.ReservedNamespaceUsers", "User_Key", "dbo.Users");
DropForeignKey("dbo.ReservedNamespaceUsers", "ReservedNamespace_Key", "dbo.ReservedNamespaces");
DropForeignKey("dbo.PackageRegistrationReservedNamespaces", "ReservedNamespace_Key", "dbo.ReservedNamespaces");
DropForeignKey("dbo.PackageRegistrationReservedNamespaces", "PackageRegistration_Key", "dbo.PackageRegistrations");
DropIndex("dbo.ReservedNamespaceUsers", new[] { "User_Key" });
DropIndex("dbo.ReservedNamespaceUsers", new[] { "ReservedNamespace_Key" });
DropIndex("dbo.PackageRegistrationReservedNamespaces", new[] { "ReservedNamespace_Key" });
DropIndex("dbo.PackageRegistrationReservedNamespaces", new[] { "PackageRegistration_Key" });
DropColumn("dbo.PackageRegistrations", "IsVerified");
DropTable("dbo.ReservedNamespaceUsers");
DropTable("dbo.PackageRegistrationReservedNamespaces");
DropTable("dbo.ReservedNamespaces");
}
}
}
Loading

0 comments on commit 4aeac85

Please sign in to comment.