#495 db migration

This commit is contained in:
Hamid Reza Mohammadi 2026-08-04 15:04:52 +03:30
parent 1b613ba397
commit 430370a6b9
4 changed files with 6316 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RMuseum.Migrations
{
/// <inheritdoc />
public partial class CommentsRatings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GanjoorComments_PoemId",
table: "GanjoorComments");
migrationBuilder.AddColumn<int>(
name: "DislikeCount",
table: "GanjoorComments",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "LikeCount",
table: "GanjoorComments",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "SortKey",
table: "GanjoorComments",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "GanjoorCommentReactions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
GanjoorCommentId = table.Column<int>(type: "int", nullable: false),
PoemId = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Value = table.Column<short>(type: "smallint", nullable: false),
ReactionDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorCommentReactions", x => x.Id);
table.ForeignKey(
name: "FK_GanjoorCommentReactions_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GanjoorCommentReactions_GanjoorComments_GanjoorCommentId",
column: x => x.GanjoorCommentId,
principalTable: "GanjoorComments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_GanjoorComments_PoemId_CommentDate",
table: "GanjoorComments",
columns: new[] { "PoemId", "CommentDate" });
migrationBuilder.CreateIndex(
name: "IX_GanjoorComments_PoemId_SortKey",
table: "GanjoorComments",
columns: new[] { "PoemId", "SortKey" });
migrationBuilder.CreateIndex(
name: "IX_GanjoorCommentReactions_GanjoorCommentId_UserId",
table: "GanjoorCommentReactions",
columns: new[] { "GanjoorCommentId", "UserId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_GanjoorCommentReactions_PoemId_UserId",
table: "GanjoorCommentReactions",
columns: new[] { "PoemId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_GanjoorCommentReactions_UserId",
table: "GanjoorCommentReactions",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GanjoorCommentReactions");
migrationBuilder.DropIndex(
name: "IX_GanjoorComments_PoemId_CommentDate",
table: "GanjoorComments");
migrationBuilder.DropIndex(
name: "IX_GanjoorComments_PoemId_SortKey",
table: "GanjoorComments");
migrationBuilder.DropColumn(
name: "DislikeCount",
table: "GanjoorComments");
migrationBuilder.DropColumn(
name: "LikeCount",
table: "GanjoorComments");
migrationBuilder.DropColumn(
name: "SortKey",
table: "GanjoorComments");
migrationBuilder.CreateIndex(
name: "IX_GanjoorComments_PoemId",
table: "GanjoorComments",
column: "PoemId");
}
}
}

View File

@ -978,15 +978,24 @@ namespace RMuseum.Migrations
b.Property<int?>("CoupletIndex")
.HasColumnType("int");
b.Property<int>("DislikeCount")
.HasColumnType("int");
b.Property<string>("HtmlComment")
.HasColumnType("nvarchar(max)");
b.Property<int?>("InReplyToId")
.HasColumnType("int");
b.Property<int>("LikeCount")
.HasColumnType("int");
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<int>("SortKey")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
@ -1008,8 +1017,6 @@ namespace RMuseum.Migrations
b.HasIndex("InReplyToId");
b.HasIndex("PoemId");
b.HasIndex("Status");
b.HasIndex("UserId");
@ -1018,6 +1025,10 @@ namespace RMuseum.Migrations
b.HasIndex("Verse2Id");
b.HasIndex("PoemId", "CommentDate");
b.HasIndex("PoemId", "SortKey");
b.ToTable("GanjoorComments");
});
@ -1050,6 +1061,41 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorReportedComments");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCommentReaction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GanjoorCommentId")
.HasColumnType("int");
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<DateTime>("ReactionDate")
.HasColumnType("datetime2");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<short>("Value")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("GanjoorCommentId", "UserId")
.IsUnique();
b.HasIndex("PoemId", "UserId");
b.ToTable("GanjoorCommentReactions");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorDuplicate", b =>
{
b.Property<int>("Id")
@ -4946,6 +4992,25 @@ namespace RMuseum.Migrations
b.Navigation("ReportedBy");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCommentReaction", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorComment", "GanjoorComment")
.WithMany()
.HasForeignKey("GanjoorCommentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GanjoorComment");
b.Navigation("User");
});
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorDuplicate", b =>
{
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "DestPoem")

View File

@ -21,9 +21,9 @@
<PackageReference Include="Betalgo.Ranul.OpenAI" Version="9.2.6" />
<PackageReference Include="DNTPersianUtils.Core" Version="7.0.0" />
<PackageReference Include="FluentFTP" Version="54.2.0" />
<PackageReference Include="HtmlSanitizer" Version="9.0.892" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.9">
<PackageReference Include="HtmlSanitizer" Version="9.1.982" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>