docs: #306 updating db migration

This commit is contained in:
Hamid Reza Mohammadi 2022-04-14 12:50:23 +04:30
parent fff4d330ef
commit ac7a609249
3 changed files with 174 additions and 17 deletions

View File

@ -12,7 +12,7 @@ using RMuseum.DbContext;
namespace RMuseum.Migrations
{
[DbContext(typeof(RMuseumDbContext))]
[Migration("20220410162939_Sections")]
[Migration("20220414081501_Sections")]
partial class Sections
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -564,6 +564,51 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorCachedRelatedPoems");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCachedRelatedSection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("FullTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("HtmlExcerpt")
.HasColumnType("nvarchar(max)");
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<int>("PoetId")
.HasColumnType("int");
b.Property<string>("PoetImageUrl")
.HasColumnType("nvarchar(max)");
b.Property<int>("PoetMorePoemsLikeThisCount")
.HasColumnType("int");
b.Property<string>("PoetName")
.HasColumnType("nvarchar(max)");
b.Property<int>("RelationOrder")
.HasColumnType("int");
b.Property<int>("SectionIndex")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PoemId", "SectionIndex");
b.ToTable("GanjoorCachedRelatedSections");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b =>
{
b.Property<int>("Id")
@ -1251,7 +1296,7 @@ namespace RMuseum.Migrations
.HasColumnType("int");
b.Property<string>("RhymeLetters")
.HasColumnType("nvarchar(max)");
.HasColumnType("nvarchar(450)");
b.Property<int>("SectionType")
.HasColumnType("int");
@ -1261,12 +1306,14 @@ namespace RMuseum.Migrations
b.HasKey("Id");
b.HasIndex("GanjoorMetreId");
b.HasIndex("PoemId");
b.HasIndex("PoetId");
b.HasIndex("RhymeLetters");
b.HasIndex("GanjoorMetreId", "RhymeLetters");
b.HasIndex("PoemId", "Index");
b.ToTable("GanjoorPoemSections");
});
@ -3161,6 +3208,17 @@ namespace RMuseum.Migrations
b.Navigation("Poem");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCachedRelatedSection", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
.WithMany()
.HasForeignKey("PoemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Poem");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorCat", "Parent")

View File

@ -32,6 +32,34 @@ namespace RMuseum.Migrations
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "GanjoorCachedRelatedSections",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PoemId = table.Column<int>(type: "int", nullable: false),
SectionIndex = table.Column<int>(type: "int", nullable: false),
PoetId = table.Column<int>(type: "int", nullable: false),
RelationOrder = table.Column<int>(type: "int", nullable: false),
PoetName = table.Column<string>(type: "nvarchar(max)", nullable: true),
PoetImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
FullUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
FullTitle = table.Column<string>(type: "nvarchar(max)", nullable: true),
HtmlExcerpt = table.Column<string>(type: "nvarchar(max)", nullable: true),
PoetMorePoemsLikeThisCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorCachedRelatedSections", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorCachedRelatedSections_GanjoorPoems_PoemId",
column: x => x.PoemId,
principalTable: "GanjoorPoems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GanjoorPoemSections",
columns: table => new
@ -45,7 +73,7 @@ namespace RMuseum.Migrations
SectionType = table.Column<int>(type: "int", nullable: false),
VerseType = table.Column<int>(type: "int", nullable: false),
GanjoorMetreId = table.Column<int>(type: "int", nullable: true),
RhymeLetters = table.Column<string>(type: "nvarchar(max)", nullable: true),
RhymeLetters = table.Column<string>(type: "nvarchar(450)", nullable: true),
PlainText = table.Column<string>(type: "nvarchar(max)", nullable: true),
HtmlText = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
@ -71,23 +99,36 @@ namespace RMuseum.Migrations
});
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoemSections_GanjoorMetreId",
table: "GanjoorPoemSections",
column: "GanjoorMetreId");
name: "IX_GanjoorCachedRelatedSections_PoemId_SectionIndex",
table: "GanjoorCachedRelatedSections",
columns: new[] { "PoemId", "SectionIndex" });
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoemSections_PoemId",
name: "IX_GanjoorPoemSections_GanjoorMetreId_RhymeLetters",
table: "GanjoorPoemSections",
column: "PoemId");
columns: new[] { "GanjoorMetreId", "RhymeLetters" });
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoemSections_PoemId_Index",
table: "GanjoorPoemSections",
columns: new[] { "PoemId", "Index" });
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoemSections_PoetId",
table: "GanjoorPoemSections",
column: "PoetId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorPoemSections_RhymeLetters",
table: "GanjoorPoemSections",
column: "RhymeLetters");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GanjoorCachedRelatedSections");
migrationBuilder.DropTable(
name: "GanjoorPoemSections");

View File

@ -562,6 +562,51 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorCachedRelatedPoems");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCachedRelatedSection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("FullTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("HtmlExcerpt")
.HasColumnType("nvarchar(max)");
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<int>("PoetId")
.HasColumnType("int");
b.Property<string>("PoetImageUrl")
.HasColumnType("nvarchar(max)");
b.Property<int>("PoetMorePoemsLikeThisCount")
.HasColumnType("int");
b.Property<string>("PoetName")
.HasColumnType("nvarchar(max)");
b.Property<int>("RelationOrder")
.HasColumnType("int");
b.Property<int>("SectionIndex")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PoemId", "SectionIndex");
b.ToTable("GanjoorCachedRelatedSections");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b =>
{
b.Property<int>("Id")
@ -1249,7 +1294,7 @@ namespace RMuseum.Migrations
.HasColumnType("int");
b.Property<string>("RhymeLetters")
.HasColumnType("nvarchar(max)");
.HasColumnType("nvarchar(450)");
b.Property<int>("SectionType")
.HasColumnType("int");
@ -1259,12 +1304,14 @@ namespace RMuseum.Migrations
b.HasKey("Id");
b.HasIndex("GanjoorMetreId");
b.HasIndex("PoemId");
b.HasIndex("PoetId");
b.HasIndex("RhymeLetters");
b.HasIndex("GanjoorMetreId", "RhymeLetters");
b.HasIndex("PoemId", "Index");
b.ToTable("GanjoorPoemSections");
});
@ -3159,6 +3206,17 @@ namespace RMuseum.Migrations
b.Navigation("Poem");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCachedRelatedSection", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
.WithMany()
.HasForeignKey("PoemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Poem");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorCat", "Parent")