Skip to content
This repository
Browse code

Fix #994 by deleting duped users before we create the index.

  • Loading branch information...
commit 15520cd5afc99475fede9e11ff3c37df75620ced 1 parent e5aedff
Tim Lovell-Smith TimLovellSmith authored
14 Website/Migrations/201303072008568_UserLookupOptimization.cs
@@ -6,6 +6,20 @@ public partial class UserLookupOptimization : DbMigration
6 6 {
7 7 public override void Up()
8 8 {
  9 + // DELETE duplicate Users from the database
  10 + // Keep the OLDER User
  11 + Sql(@"WITH NumberedRows
  12 +AS
  13 +(
  14 +
  15 + SELECT Row_number() OVER
  16 +(PARTITION BY Username ORDER BY Username, [Key] ASC)
  17 +
  18 + RowId, * from Users
  19 +)
  20 +
  21 +DELETE * FROM NumberedRows WHERE RowId > 1");
  22 +
9 23 AlterColumn("Users", "EmailAddress", c => c.String(maxLength: 256));
10 24 AlterColumn("Users", "UnconfirmedEmailAddress", c => c.String(maxLength: 256));
11 25 AlterColumn("Users", "HashedPassword", c => c.String(nullable: false, maxLength: 256));

0 comments on commit 15520cd

Please sign in to comment.
Something went wrong with that request. Please try again.