-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f862709
commit 9abf738
Showing
5 changed files
with
207 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
29 changes: 29 additions & 0 deletions
29
src/NuGetGallery/Migrations/201705032101231_SecurityPoliciesFix.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
src/NuGetGallery/Migrations/201705032101231_SecurityPoliciesFix.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,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) { } | ||
} | ||
} | ||
} |
Oops, something went wrong.