Skip to content
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

Fix migration issue #3865 #3872

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/NuGetGallery.Core/Entities/UserSecurityPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public UserSecurityPolicy(string name)
/// Type name for the policy handler that provides policy behavior.
/// </summary>
[Required]
[StringLength(256)]
public string Name { get; set; }

/// <summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace NuGetGallery.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class SecurityPoliciesFix : DbMigration
{
public override void Up()
{
DropUserSecurityPoliciesIfExists();

CreateTable(
"dbo.UserSecurityPolicies",
c => new
{
Key = c.Int(nullable: false, identity: true),
UserKey = c.Int(nullable: false),
Name = c.String(nullable: false, maxLength: 256),
Value = c.String(),
})
.PrimaryKey(t => t.Key)
.ForeignKey("dbo.Users", t => t.UserKey, cascadeDelete: true)
.Index(t => t.UserKey);

}

public override void Down()
{
DropForeignKey("dbo.UserSecurityPolicies", "UserKey", "dbo.Users");
DropIndex("dbo.UserSecurityPolicies", new[] { "UserKey" });
DropTable("dbo.UserSecurityPolicies");
}

private void DropUserSecurityPoliciesIfExists()
{
try
{
DropForeignKey("dbo.UserSecurityPolicies", "UserKey", "dbo.Users");
DropTable("dbo.UserSecurityPolicies");
}
catch (Exception) { }
}
}
}
Loading