🗃️ Add post award database

This commit is contained in:
2025-09-05 00:24:54 +08:00
parent 9c078db564
commit 5e328509bd
3 changed files with 2264 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddPostAwardScore : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "awarded_score",
table: "posts",
type: "numeric",
nullable: false,
defaultValue: 0m);
migrationBuilder.CreateTable(
name: "post_awards",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
amount = table.Column<decimal>(type: "numeric", nullable: false),
attitude = table.Column<int>(type: "integer", nullable: false),
message = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
post_id = table.Column<Guid>(type: "uuid", nullable: false),
account_id = table.Column<Guid>(type: "uuid", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_post_awards", x => x.id);
table.ForeignKey(
name: "fk_post_awards_posts_post_id",
column: x => x.post_id,
principalTable: "posts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_post_awards_post_id",
table: "post_awards",
column: "post_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "post_awards");
migrationBuilder.DropColumn(
name: "awarded_score",
table: "posts");
}
}
}

View File

@@ -529,6 +529,10 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("jsonb")
.HasColumnName("attachments");
b.Property<decimal>("AwardedScore")
.HasColumnType("numeric")
.HasColumnName("awarded_score");
b.Property<string>("Content")
.HasColumnType("text")
.HasColumnName("content");
@@ -659,6 +663,55 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("posts", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PostAward", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Guid>("AccountId")
.HasColumnType("uuid")
.HasColumnName("account_id");
b.Property<decimal>("Amount")
.HasColumnType("numeric")
.HasColumnName("amount");
b.Property<int>("Attitude")
.HasColumnType("integer")
.HasColumnName("attitude");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<string>("Message")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("message");
b.Property<Guid>("PostId")
.HasColumnType("uuid")
.HasColumnName("post_id");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_post_awards");
b.HasIndex("PostId")
.HasDatabaseName("ix_post_awards_post_id");
b.ToTable("post_awards", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PostCategory", b =>
{
b.Property<Guid>("Id")
@@ -1770,6 +1823,18 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("RepliedPost");
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PostAward", b =>
{
b.HasOne("DysonNetwork.Sphere.Post.Post", "Post")
.WithMany("Awards")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_post_awards_posts_post_id");
b.Navigation("Post");
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PostCategorySubscription", b =>
{
b.HasOne("DysonNetwork.Sphere.Post.PostCategory", "Category")
@@ -2021,6 +2086,8 @@ namespace DysonNetwork.Sphere.Migrations
modelBuilder.Entity("DysonNetwork.Sphere.Post.Post", b =>
{
b.Navigation("Awards");
b.Navigation("Reactions");
});