🗃️ Migrate previous changes

This commit is contained in:
LittleSheep 2025-06-12 01:01:52 +08:00
parent ffb3f83b96
commit 34902d0486
3 changed files with 3875 additions and 0 deletions

View File

@ -0,0 +1,143 @@
using System;
using DysonNetwork.Sphere.Wallet;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class BetterRecyclingFilesAndWalletSubscriptions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "is_marked_recycle",
table: "files",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "location",
table: "account_profiles",
type: "character varying(1024)",
maxLength: 1024,
nullable: true);
migrationBuilder.AddColumn<SubscriptionReferenceObject>(
name: "stellar_membership",
table: "account_profiles",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "time_zone",
table: "account_profiles",
type: "character varying(1024)",
maxLength: 1024,
nullable: true);
migrationBuilder.CreateTable(
name: "wallet_coupons",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
identifier = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
code = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
affected_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
expired_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
discount_amount = table.Column<decimal>(type: "numeric", nullable: true),
discount_rate = table.Column<double>(type: "double precision", nullable: true),
max_usage = table.Column<int>(type: "integer", nullable: true),
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_wallet_coupons", x => x.id);
});
migrationBuilder.CreateTable(
name: "wallet_subscriptions",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
begun_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
ended_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
identifier = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
is_active = table.Column<bool>(type: "boolean", nullable: false),
is_free_trial = table.Column<bool>(type: "boolean", nullable: false),
status = table.Column<int>(type: "integer", nullable: false),
payment_method = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
payment_details = table.Column<PaymentDetails>(type: "jsonb", nullable: false),
base_price = table.Column<decimal>(type: "numeric", nullable: false),
coupon_id = table.Column<Guid>(type: "uuid", nullable: true),
renewal_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
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_wallet_subscriptions", x => x.id);
table.ForeignKey(
name: "fk_wallet_subscriptions_accounts_account_id",
column: x => x.account_id,
principalTable: "accounts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_wallet_subscriptions_wallet_coupons_coupon_id",
column: x => x.coupon_id,
principalTable: "wallet_coupons",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "ix_wallet_subscriptions_account_id",
table: "wallet_subscriptions",
column: "account_id");
migrationBuilder.CreateIndex(
name: "ix_wallet_subscriptions_coupon_id",
table: "wallet_subscriptions",
column: "coupon_id");
migrationBuilder.CreateIndex(
name: "ix_wallet_subscriptions_identifier",
table: "wallet_subscriptions",
column: "identifier");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "wallet_subscriptions");
migrationBuilder.DropTable(
name: "wallet_coupons");
migrationBuilder.DropColumn(
name: "is_marked_recycle",
table: "files");
migrationBuilder.DropColumn(
name: "location",
table: "account_profiles");
migrationBuilder.DropColumn(
name: "stellar_membership",
table: "account_profiles");
migrationBuilder.DropColumn(
name: "time_zone",
table: "account_profiles");
}
}
}

View File

@ -6,6 +6,7 @@ using DysonNetwork.Sphere;
using DysonNetwork.Sphere.Account;
using DysonNetwork.Sphere.Chat;
using DysonNetwork.Sphere.Storage;
using DysonNetwork.Sphere.Wallet;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@ -611,6 +612,11 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("timestamp with time zone")
.HasColumnName("last_seen_at");
b.Property<string>("Location")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("location");
b.Property<string>("MiddleName")
.HasMaxLength(256)
.HasColumnType("character varying(256)")
@ -630,6 +636,15 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("character varying(1024)")
.HasColumnName("pronouns");
b.Property<SubscriptionReferenceObject>("StellarMembership")
.HasColumnType("jsonb")
.HasColumnName("stellar_membership");
b.Property<string>("TimeZone")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("time_zone");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
@ -2238,6 +2253,10 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("character varying(256)")
.HasColumnName("hash");
b.Property<bool>("IsMarkedRecycle")
.HasColumnType("boolean")
.HasColumnName("is_marked_recycle");
b.Property<Guid?>("MessageId")
.HasColumnType("uuid")
.HasColumnName("message_id");
@ -2357,6 +2376,61 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("file_references", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Wallet.Coupon", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Instant?>("AffectedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("affected_at");
b.Property<string>("Code")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("code");
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<decimal?>("DiscountAmount")
.HasColumnType("numeric")
.HasColumnName("discount_amount");
b.Property<double?>("DiscountRate")
.HasColumnType("double precision")
.HasColumnName("discount_rate");
b.Property<Instant?>("ExpiredAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("expired_at");
b.Property<string>("Identifier")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("identifier");
b.Property<int?>("MaxUsage")
.HasColumnType("integer")
.HasColumnName("max_usage");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_wallet_coupons");
b.ToTable("wallet_coupons", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Wallet.Order", b =>
{
b.Property<Guid>("Id")
@ -2426,6 +2500,93 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("payment_orders", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Wallet.Subscription", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Guid>("AccountId")
.HasColumnType("uuid")
.HasColumnName("account_id");
b.Property<decimal>("BasePrice")
.HasColumnType("numeric")
.HasColumnName("base_price");
b.Property<Instant>("BegunAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("begun_at");
b.Property<Guid?>("CouponId")
.HasColumnType("uuid")
.HasColumnName("coupon_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<Instant?>("EndedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("ended_at");
b.Property<string>("Identifier")
.IsRequired()
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("identifier");
b.Property<bool>("IsActive")
.HasColumnType("boolean")
.HasColumnName("is_active");
b.Property<bool>("IsFreeTrial")
.HasColumnType("boolean")
.HasColumnName("is_free_trial");
b.Property<PaymentDetails>("PaymentDetails")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("payment_details");
b.Property<string>("PaymentMethod")
.IsRequired()
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("payment_method");
b.Property<Instant?>("RenewalAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("renewal_at");
b.Property<int>("Status")
.HasColumnType("integer")
.HasColumnName("status");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_wallet_subscriptions");
b.HasIndex("AccountId")
.HasDatabaseName("ix_wallet_subscriptions_account_id");
b.HasIndex("CouponId")
.HasDatabaseName("ix_wallet_subscriptions_coupon_id");
b.HasIndex("Identifier")
.HasDatabaseName("ix_wallet_subscriptions_identifier");
b.ToTable("wallet_subscriptions", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.Wallet.Transaction", b =>
{
b.Property<Guid>("Id")
@ -3199,6 +3360,25 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("Transaction");
});
modelBuilder.Entity("DysonNetwork.Sphere.Wallet.Subscription", b =>
{
b.HasOne("DysonNetwork.Sphere.Account.Account", "Account")
.WithMany("Subscriptions")
.HasForeignKey("AccountId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_wallet_subscriptions_accounts_account_id");
b.HasOne("DysonNetwork.Sphere.Wallet.Coupon", "Coupon")
.WithMany()
.HasForeignKey("CouponId")
.HasConstraintName("fk_wallet_subscriptions_wallet_coupons_coupon_id");
b.Navigation("Account");
b.Navigation("Coupon");
});
modelBuilder.Entity("DysonNetwork.Sphere.Wallet.Transaction", b =>
{
b.HasOne("DysonNetwork.Sphere.Wallet.Wallet", "PayeeWallet")
@ -3309,6 +3489,8 @@ namespace DysonNetwork.Sphere.Migrations
.IsRequired();
b.Navigation("Sessions");
b.Navigation("Subscriptions");
});
modelBuilder.Entity("DysonNetwork.Sphere.Chat.ChatRoom", b =>