db cleanup

This commit is contained in:
Paul Schneider 2025-07-15 15:49:48 +01:00
commit fc15e42efe
6 changed files with 3566 additions and 128 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,117 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class dbCleanup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_BankBook_BankStatus_BalanceId",
table: "BankBook");
migrationBuilder.DropTable(
name: "OAuth2Tokens");
migrationBuilder.DropTable(
name: "RefreshTokens");
migrationBuilder.DropPrimaryKey(
name: "PK_BankBook",
table: "BankBook");
migrationBuilder.RenameTable(
name: "BankBook",
newName: "BalanceImpact");
migrationBuilder.RenameIndex(
name: "IX_BankBook_BalanceId",
table: "BalanceImpact",
newName: "IX_BalanceImpact_BalanceId");
migrationBuilder.AddPrimaryKey(
name: "PK_BalanceImpact",
table: "BalanceImpact",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_BalanceImpact_BankStatus_BalanceId",
table: "BalanceImpact",
column: "BalanceId",
principalTable: "BankStatus",
principalColumn: "UserId",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_BalanceImpact_BankStatus_BalanceId",
table: "BalanceImpact");
migrationBuilder.DropPrimaryKey(
name: "PK_BalanceImpact",
table: "BalanceImpact");
migrationBuilder.RenameTable(
name: "BalanceImpact",
newName: "BankBook");
migrationBuilder.RenameIndex(
name: "IX_BalanceImpact_BalanceId",
table: "BankBook",
newName: "IX_BankBook_BalanceId");
migrationBuilder.AddPrimaryKey(
name: "PK_BankBook",
table: "BankBook",
column: "Id");
migrationBuilder.CreateTable(
name: "OAuth2Tokens",
columns: table => new
{
UserId = table.Column<string>(type: "text", nullable: false),
AccessToken = table.Column<string>(type: "text", nullable: false),
Expiration = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ExpiresIn = table.Column<string>(type: "text", nullable: false),
RefreshToken = table.Column<string>(type: "text", nullable: false),
TokenType = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OAuth2Tokens", x => x.UserId);
});
migrationBuilder.CreateTable(
name: "RefreshTokens",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
ExpiresUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
IssuedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ProtectedTicket = table.Column<string>(type: "text", nullable: false),
Subject = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshTokens", x => x.Id);
});
migrationBuilder.AddForeignKey(
name: "FK_BankBook_BankStatus_BalanceId",
table: "BankBook",
column: "BalanceId",
principalTable: "BankStatus",
principalColumn: "UserId",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -471,65 +471,6 @@ namespace Yavsc.Migrations
b.ToTable("Applications");
});
modelBuilder.Entity("Yavsc.Models.Auth.OAuth2Tokens", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("AccessToken")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Expiration")
.HasColumnType("timestamp with time zone");
b.Property<string>("ExpiresIn")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TokenType")
.IsRequired()
.HasColumnType("text");
b.HasKey("UserId");
b.ToTable("OAuth2Tokens");
});
modelBuilder.Entity("Yavsc.Models.Auth.RefreshToken", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("ExpiresUtc")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("IssuedUtc")
.HasColumnType("timestamp with time zone");
b.Property<string>("ProtectedTicket")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.ToTable("RefreshTokens");
});
modelBuilder.Entity("Yavsc.Models.Auth.Scope", b =>
{
b.Property<string>("Id")
@ -571,7 +512,7 @@ namespace Yavsc.Migrations
b.HasIndex("BalanceId");
b.ToTable("BankBook");
b.ToTable("BalanceImpact");
});
modelBuilder.Entity("Yavsc.Models.Bank.BankIdentity", b =>