Organization publishers, subscriptions to publishers

This commit is contained in:
2025-05-12 21:48:16 +08:00
parent b20bc3c443
commit b275f06061
14 changed files with 6197 additions and 19 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddPublisherSubscription : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "publisher_subscriptions",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
publisher_id = table.Column<long>(type: "bigint", nullable: false),
account_id = table.Column<long>(type: "bigint", nullable: false),
status = table.Column<int>(type: "integer", nullable: false),
tier = table.Column<int>(type: "integer", 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_publisher_subscriptions", x => x.id);
table.ForeignKey(
name: "fk_publisher_subscriptions_accounts_account_id",
column: x => x.account_id,
principalTable: "accounts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_publisher_subscriptions_publishers_publisher_id",
column: x => x.publisher_id,
principalTable: "publishers",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_publisher_subscriptions_account_id",
table: "publisher_subscriptions",
column: "account_id");
migrationBuilder.CreateIndex(
name: "ix_publisher_subscriptions_publisher_id",
table: "publisher_subscriptions",
column: "publisher_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "publisher_subscriptions");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class PublisherWithOrganization : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "realm_id",
table: "publishers",
type: "bigint",
nullable: true);
migrationBuilder.CreateIndex(
name: "ix_publishers_realm_id",
table: "publishers",
column: "realm_id");
migrationBuilder.AddForeignKey(
name: "fk_publishers_realms_realm_id",
table: "publishers",
column: "realm_id",
principalTable: "realms",
principalColumn: "id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_publishers_realms_realm_id",
table: "publishers");
migrationBuilder.DropIndex(
name: "ix_publishers_realm_id",
table: "publishers");
migrationBuilder.DropColumn(
name: "realm_id",
table: "publishers");
}
}
}

View File

@ -1575,6 +1575,10 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("integer")
.HasColumnName("publisher_type");
b.Property<long?>("RealmId")
.HasColumnType("bigint")
.HasColumnName("realm_id");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
@ -1595,6 +1599,9 @@ namespace DysonNetwork.Sphere.Migrations
b.HasIndex("PictureId")
.HasDatabaseName("ix_publishers_picture_id");
b.HasIndex("RealmId")
.HasDatabaseName("ix_publishers_realm_id");
b.ToTable("publishers", (string)null);
});
@ -1637,6 +1644,53 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("publisher_members", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PublisherSubscription", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<long>("AccountId")
.HasColumnType("bigint")
.HasColumnName("account_id");
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<long>("PublisherId")
.HasColumnType("bigint")
.HasColumnName("publisher_id");
b.Property<int>("Status")
.HasColumnType("integer")
.HasColumnName("status");
b.Property<int>("Tier")
.HasColumnType("integer")
.HasColumnName("tier");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_publisher_subscriptions");
b.HasIndex("AccountId")
.HasDatabaseName("ix_publisher_subscriptions_account_id");
b.HasIndex("PublisherId")
.HasDatabaseName("ix_publisher_subscriptions_publisher_id");
b.ToTable("publisher_subscriptions", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Realm.Realm", b =>
{
b.Property<long>("Id")
@ -2442,11 +2496,18 @@ namespace DysonNetwork.Sphere.Migrations
.HasForeignKey("PictureId")
.HasConstraintName("fk_publishers_files_picture_id");
b.HasOne("DysonNetwork.Sphere.Realm.Realm", "Realm")
.WithMany()
.HasForeignKey("RealmId")
.HasConstraintName("fk_publishers_realms_realm_id");
b.Navigation("Account");
b.Navigation("Background");
b.Navigation("Picture");
b.Navigation("Realm");
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PublisherMember", b =>
@ -2470,6 +2531,27 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("Publisher");
});
modelBuilder.Entity("DysonNetwork.Sphere.Post.PublisherSubscription", b =>
{
b.HasOne("DysonNetwork.Sphere.Account.Account", "Account")
.WithMany()
.HasForeignKey("AccountId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_publisher_subscriptions_accounts_account_id");
b.HasOne("DysonNetwork.Sphere.Post.Publisher", "Publisher")
.WithMany("Subscriptions")
.HasForeignKey("PublisherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_publisher_subscriptions_publishers_publisher_id");
b.Navigation("Account");
b.Navigation("Publisher");
});
modelBuilder.Entity("DysonNetwork.Sphere.Realm.Realm", b =>
{
b.HasOne("DysonNetwork.Sphere.Account.Account", "Account")
@ -2676,6 +2758,8 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("Members");
b.Navigation("Posts");
b.Navigation("Subscriptions");
});
modelBuilder.Entity("DysonNetwork.Sphere.Realm.Realm", b =>