#221 fixing indexes

This commit is contained in:
Hamid Reza Mohammadi 2021-10-13 20:14:19 +03:30
parent 77f56add0e
commit 218f122edc
4 changed files with 3240 additions and 5 deletions

View File

@ -121,8 +121,7 @@ namespace RMuseum.DbContext
.IsUnique();
builder.Entity<GanjoorUserBookmark>()
.HasIndex(b => new { b.UserId, b.PoemId, b.VerseId })
.IsUnique();
.HasIndex(b => new { b.UserId, b.PoemId, b.CoupletIndex });
builder.Entity<GanjoorVerseNumber>()
.HasIndex(n => new { n.NumberingId, n.PoemId, n.CoupletIndex })

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorUserBookmarkCoupletIndex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_VerseId",
table: "GanjoorUserBookmarks");
migrationBuilder.CreateIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_CoupletIndex",
table: "GanjoorUserBookmarks",
columns: new[] { "UserId", "PoemId", "CoupletIndex" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_CoupletIndex",
table: "GanjoorUserBookmarks");
migrationBuilder.CreateIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_VerseId",
table: "GanjoorUserBookmarks",
columns: new[] { "UserId", "PoemId", "VerseId" },
unique: true,
filter: "[VerseId] IS NOT NULL");
}
}
}

View File

@ -1046,9 +1046,7 @@ namespace RMuseum.Migrations
b.HasIndex("PoemId");
b.HasIndex("UserId", "PoemId", "VerseId")
.IsUnique()
.HasFilter("[VerseId] IS NOT NULL");
b.HasIndex("UserId", "PoemId", "CoupletIndex");
b.ToTable("GanjoorUserBookmarks");
});