-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4394 from NuGet/prefix-db-changes
[Prefix] DB changes for Prefix reservation
- Loading branch information
Showing
8 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// 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. | ||
|
||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public class ReservedNamespace : IEntity | ||
{ | ||
public ReservedNamespace() | ||
: this(value: null, isSharedNamespace: false, isExactMatch: false) | ||
{ | ||
} | ||
|
||
public ReservedNamespace(string value, bool isSharedNamespace, bool isExactMatch) | ||
{ | ||
Value = value; | ||
IsSharedNamespace = isSharedNamespace; | ||
IsPrefix = isExactMatch; | ||
PackageRegistrations = new HashSet<PackageRegistration>(); | ||
ReservedNamespaceOwners = new HashSet<User>(); | ||
} | ||
|
||
[StringLength(CoreConstants.MaxPackageIdLength)] | ||
[Required] | ||
public string Value { get; set; } | ||
|
||
public bool IsSharedNamespace { get; set; } | ||
|
||
public bool IsPrefix { get; set; } | ||
|
||
public virtual ICollection<PackageRegistration> PackageRegistrations { get; set; } | ||
public virtual ICollection<User> ReservedNamespaceOwners { get; set; } | ||
|
||
[Key] | ||
public int Key { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/NuGetGallery/Migrations/201707131923337_PrefixReservation.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
src/NuGetGallery/Migrations/201707131923337_PrefixReservation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
namespace NuGetGallery.Migrations | ||
{ | ||
using System; | ||
using System.Data.Entity.Migrations; | ||
|
||
public partial class PrefixReservation : DbMigration | ||
{ | ||
public override void Up() | ||
{ | ||
CreateTable( | ||
"dbo.ReservedNamespaces", | ||
c => new | ||
{ | ||
Key = c.Int(nullable: false, identity: true), | ||
Value = c.String(nullable: false, maxLength: 128), | ||
IsSharedNamespace = c.Boolean(nullable: false), | ||
IsPrefix = c.Boolean(nullable: false), | ||
}) | ||
.PrimaryKey(t => t.Key); | ||
|
||
CreateTable( | ||
"dbo.PackageRegistrationReservedNamespaces", | ||
c => new | ||
{ | ||
PackageRegistration_Key = c.Int(nullable: false), | ||
ReservedNamespace_Key = c.Int(nullable: false), | ||
}) | ||
.PrimaryKey(t => new { t.PackageRegistration_Key, t.ReservedNamespace_Key }) | ||
.ForeignKey("dbo.PackageRegistrations", t => t.PackageRegistration_Key, cascadeDelete: true) | ||
.ForeignKey("dbo.ReservedNamespaces", t => t.ReservedNamespace_Key, cascadeDelete: true) | ||
.Index(t => t.PackageRegistration_Key) | ||
.Index(t => t.ReservedNamespace_Key); | ||
|
||
CreateTable( | ||
"dbo.ReservedNamespaceUsers", | ||
c => new | ||
{ | ||
ReservedNamespace_Key = c.Int(nullable: false), | ||
User_Key = c.Int(nullable: false), | ||
}) | ||
.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.ReservedNamespace_Key) | ||
.Index(t => t.User_Key); | ||
|
||
AddColumn("dbo.PackageRegistrations", "IsVerified", c => c.Boolean(nullable: false)); | ||
} | ||
|
||
public override void Down() | ||
{ | ||
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"); | ||
} | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
src/NuGetGallery/Migrations/201707131923337_PrefixReservation.resx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters