-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Prefix] Merge prefix reservation DB schema and service changes into …
…DEV (#4590) Merge DEV changes and add prefix reservation db schema, service changes.
- Loading branch information
1 parent
4771a58
commit 450fc6c
Showing
25 changed files
with
1,551 additions
and
93 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
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, isPrefix: false) | ||
{ | ||
} | ||
|
||
public ReservedNamespace(string value, bool isSharedNamespace, bool isPrefix) | ||
{ | ||
Value = value; | ||
IsSharedNamespace = isSharedNamespace; | ||
IsPrefix = isPrefix; | ||
PackageRegistrations = new HashSet<PackageRegistration>(); | ||
Owners = 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> Owners { get; set; } | ||
|
||
[Key] | ||
public int Key { get; set; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/NuGetGallery.Core/Entities/SuspendDbExecutionStrategy.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,23 @@ | ||
// 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; | ||
|
||
namespace NuGetGallery | ||
{ | ||
/// <summary> | ||
/// Define the execution strategy for the EntitiesConfiguration for connection resiliency and retries | ||
/// </summary> | ||
public class SuspendDbExecutionStrategy : IDisposable | ||
{ | ||
public SuspendDbExecutionStrategy() | ||
{ | ||
EntitiesConfiguration.SuspendExecutionStrategy = true; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
EntitiesConfiguration.SuspendExecutionStrategy = false; | ||
} | ||
} | ||
} |
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
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/201708241907124_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/201708241907124_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.ReservedNamespaceOwners", | ||
c => new | ||
{ | ||
ReservedNamespaceKey = c.Int(nullable: false), | ||
UserKey = c.Int(nullable: false), | ||
}) | ||
.PrimaryKey(t => new { t.ReservedNamespaceKey, t.UserKey }) | ||
.ForeignKey("dbo.ReservedNamespaces", t => t.ReservedNamespaceKey, cascadeDelete: true) | ||
.ForeignKey("dbo.Users", t => t.UserKey, cascadeDelete: true) | ||
.Index(t => t.ReservedNamespaceKey) | ||
.Index(t => t.UserKey); | ||
|
||
CreateTable( | ||
"dbo.ReservedNamespaceRegistrations", | ||
c => new | ||
{ | ||
ReservedNamespaceKey = c.Int(nullable: false), | ||
PackageRegistrationKey = c.Int(nullable: false), | ||
}) | ||
.PrimaryKey(t => new { t.ReservedNamespaceKey, t.PackageRegistrationKey }) | ||
.ForeignKey("dbo.ReservedNamespaces", t => t.ReservedNamespaceKey, cascadeDelete: true) | ||
.ForeignKey("dbo.PackageRegistrations", t => t.PackageRegistrationKey, cascadeDelete: true) | ||
.Index(t => t.ReservedNamespaceKey) | ||
.Index(t => t.PackageRegistrationKey); | ||
|
||
AddColumn("dbo.PackageRegistrations", "IsVerified", c => c.Boolean(nullable: false)); | ||
} | ||
|
||
public override void Down() | ||
{ | ||
DropForeignKey("dbo.ReservedNamespaceRegistrations", "PackageRegistrationKey", "dbo.PackageRegistrations"); | ||
DropForeignKey("dbo.ReservedNamespaceRegistrations", "ReservedNamespaceKey", "dbo.ReservedNamespaces"); | ||
DropForeignKey("dbo.ReservedNamespaceOwners", "UserKey", "dbo.Users"); | ||
DropForeignKey("dbo.ReservedNamespaceOwners", "ReservedNamespaceKey", "dbo.ReservedNamespaces"); | ||
DropIndex("dbo.ReservedNamespaceRegistrations", new[] { "PackageRegistrationKey" }); | ||
DropIndex("dbo.ReservedNamespaceRegistrations", new[] { "ReservedNamespaceKey" }); | ||
DropIndex("dbo.ReservedNamespaceOwners", new[] { "UserKey" }); | ||
DropIndex("dbo.ReservedNamespaceOwners", new[] { "ReservedNamespaceKey" }); | ||
DropColumn("dbo.PackageRegistrations", "IsVerified"); | ||
DropTable("dbo.ReservedNamespaceRegistrations"); | ||
DropTable("dbo.ReservedNamespaceOwners"); | ||
DropTable("dbo.ReservedNamespaces"); | ||
} | ||
} | ||
} |
Oops, something went wrong.