#203 adding db migration

This commit is contained in:
Hamid Reza Mohammadi 2021-09-11 19:49:57 +04:30
parent 79fe3187e3
commit c757270c1d
4 changed files with 3257 additions and 0 deletions

View File

@ -124,6 +124,11 @@ namespace RMuseum.DbContext
.HasIndex(t => new { t.LanguageId, t.PoemId })
.IsUnique();
builder.Entity<GanjoorPoemTranslation>()
.HasOne(e => e.Language)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
builder.Entity<GanjoorVerseTranslation>()
.HasIndex(t => new { t.LanguageId, t.VerseId })
.IsUnique();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class Translations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GanjoorLanguages",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(450)", nullable: true),
RightToLeft = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorLanguages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PoemTranslations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
LanguageId = table.Column<int>(type: "int", nullable: false),
PoemId = table.Column<int>(type: "int", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Published = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PoemTranslations", x => x.Id);
table.ForeignKey(
name: "FK_PoemTranslations_GanjoorPoems_PoemId",
column: x => x.PoemId,
principalTable: "GanjoorPoems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PoemTranslations_PoemTranslations_LanguageId",
column: x => x.LanguageId,
principalTable: "PoemTranslations",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "VerseTranslations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
VerseId = table.Column<int>(type: "int", nullable: false),
LanguageId = table.Column<int>(type: "int", nullable: false),
TText = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VerseTranslations", x => x.Id);
table.ForeignKey(
name: "FK_VerseTranslations_GanjoorLanguages_LanguageId",
column: x => x.LanguageId,
principalTable: "GanjoorLanguages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_VerseTranslations_GanjoorVerses_VerseId",
column: x => x.VerseId,
principalTable: "GanjoorVerses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_GanjoorLanguages_Name",
table: "GanjoorLanguages",
column: "Name",
unique: true,
filter: "[Name] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_PoemTranslations_LanguageId_PoemId",
table: "PoemTranslations",
columns: new[] { "LanguageId", "PoemId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_PoemTranslations_PoemId",
table: "PoemTranslations",
column: "PoemId");
migrationBuilder.CreateIndex(
name: "IX_VerseTranslations_LanguageId_VerseId",
table: "VerseTranslations",
columns: new[] { "LanguageId", "VerseId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_VerseTranslations_VerseId",
table: "VerseTranslations",
column: "VerseId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PoemTranslations");
migrationBuilder.DropTable(
name: "VerseTranslations");
migrationBuilder.DropTable(
name: "GanjoorLanguages");
}
}
}

View File

@ -583,6 +583,28 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorHealthCheckErrors");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorLanguage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<bool>("RightToLeft")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasFilter("[Name] IS NOT NULL");
b.ToTable("GanjoorLanguages");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorMetre", b =>
{
b.Property<int>("Id")
@ -852,6 +874,35 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorPoemCorrections");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoemTranslation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("LanguageId")
.HasColumnType("int");
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<bool>("Published")
.HasColumnType("bit");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("PoemId");
b.HasIndex("LanguageId", "PoemId")
.IsUnique();
b.ToTable("PoemTranslations");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoet", b =>
{
b.Property<int>("Id")
@ -934,6 +985,32 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorVerses");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerseTranslation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("LanguageId")
.HasColumnType("int");
b.Property<string>("TText")
.HasColumnType("nvarchar(max)");
b.Property<int>("VerseId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("VerseId");
b.HasIndex("LanguageId", "VerseId")
.IsUnique();
b.ToTable("VerseTranslations");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerseVOrderText", b =>
{
b.Property<int>("Id")
@ -2481,6 +2558,25 @@ namespace RMuseum.Migrations
b.Navigation("User");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoemTranslation", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoemTranslation", "Language")
.WithMany()
.HasForeignKey("LanguageId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
.WithMany()
.HasForeignKey("PoemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Language");
b.Navigation("Poem");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoet", b =>
{
b.HasOne("RSecurityBackend.Models.Image.RImage", "RImage")
@ -2512,6 +2608,25 @@ namespace RMuseum.Migrations
b.Navigation("Poem");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerseTranslation", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorLanguage", "Language")
.WithMany()
.HasForeignKey("LanguageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("RMuseum.Models.Ganjoor.GanjoorVerse", "Verse")
.WithMany()
.HasForeignKey("VerseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Language");
b.Navigation("Verse");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerseVOrderText", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoemCorrection", null)