#221 removing bookmarks verse id dependency

This commit is contained in:
Hamid Reza Mohammadi 2021-10-13 19:55:53 +03:30
parent 9c0f55b5ba
commit 290b8fa212
3 changed files with 3280 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorUserBookmarkRemoveVerseIdDep : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_VerseId",
table: "GanjoorUserBookmarks");
migrationBuilder.AlterColumn<int>(
name: "VerseId",
table: "GanjoorUserBookmarks",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.CreateIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_VerseId",
table: "GanjoorUserBookmarks",
columns: new[] { "UserId", "PoemId", "VerseId" },
unique: true,
filter: "[VerseId] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_VerseId",
table: "GanjoorUserBookmarks");
migrationBuilder.AlterColumn<int>(
name: "VerseId",
table: "GanjoorUserBookmarks",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_GanjoorUserBookmarks_UserId_PoemId_VerseId",
table: "GanjoorUserBookmarks",
columns: new[] { "UserId", "PoemId", "VerseId" },
unique: true);
}
}
}

View File

@ -1039,7 +1039,7 @@ namespace RMuseum.Migrations
b.Property<int?>("Verse2Id")
.HasColumnType("int");
b.Property<int>("VerseId")
b.Property<int?>("VerseId")
.HasColumnType("int");
b.HasKey("Id");
@ -1051,7 +1051,8 @@ namespace RMuseum.Migrations
b.HasIndex("VerseId");
b.HasIndex("UserId", "PoemId", "VerseId")
.IsUnique();
.IsUnique()
.HasFilter("[VerseId] IS NOT NULL");
b.ToTable("GanjoorUserBookmarks");
});
@ -2779,8 +2780,7 @@ namespace RMuseum.Migrations
b.HasOne("RMuseum.Models.Ganjoor.GanjoorVerse", "Verse")
.WithMany()
.HasForeignKey("VerseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Poem");