Add unqiue contraint for NormalizedUsername

This commit is contained in:
JPVenson
2026-05-24 11:04:01 +00:00
parent e5c34e7096
commit eece62a90b
4 changed files with 20 additions and 0 deletions

View File

@@ -50,6 +50,10 @@ namespace Jellyfin.Database.Implementations.ModelConfiguration
builder
.HasIndex(entity => entity.Username)
.IsUnique();
builder
.HasIndex(entity => entity.NormalizedUsername)
.IsUnique();
}
}
}

View File

@@ -1356,6 +1356,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("Username")
.IsUnique();
b.HasIndex("NormalizedUsername")
.IsUnique();
b.ToTable("Users");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);

View File

@@ -18,6 +18,12 @@ namespace Jellyfin.Server.Implementations.Migrations
maxLength: 255,
nullable: false,
defaultValue: string.Empty);
migrationBuilder.CreateIndex(
name: "IX_Users_NormalizedUsername",
table: "Users",
column: "NormalizedUsername",
unique: true);
}
/// <inheritdoc />
@@ -26,6 +32,10 @@ namespace Jellyfin.Server.Implementations.Migrations
migrationBuilder.DropColumn(
name: "NormalizedUsername",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_Users_NormalizedUsername",
table: "Users");
}
}
}

View File

@@ -1350,6 +1350,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("Id");
b.HasIndex("NormalizedUsername")
.IsUnique();
b.HasIndex("Username")
.IsUnique();