🗃️ Remove the fk of session in action logs in order to fix logout

This commit is contained in:
LittleSheep 2025-06-25 00:03:50 +08:00
parent d9747daab9
commit c6cb2a0dc3
4 changed files with 3662 additions and 12 deletions

View File

@ -4,7 +4,7 @@ using Point = NetTopologySuite.Geometries.Point;
namespace DysonNetwork.Sphere.Account; namespace DysonNetwork.Sphere.Account;
public class ActionLogType public abstract class ActionLogType
{ {
public const string NewLogin = "login"; public const string NewLogin = "login";
public const string ChallengeAttempt = "challenges.attempt"; public const string ChallengeAttempt = "challenges.attempt";
@ -55,5 +55,4 @@ public class ActionLog : ModelBase
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
public Account Account { get; set; } = null!; public Account Account { get; set; } = null!;
public Guid? SessionId { get; set; } public Guid? SessionId { get; set; }
public Auth.Session? Session { get; set; } = null!;
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class DropActionLogSessionFk : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_action_logs_auth_sessions_session_id",
table: "action_logs");
migrationBuilder.DropIndex(
name: "ix_action_logs_session_id",
table: "action_logs");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "ix_action_logs_session_id",
table: "action_logs",
column: "session_id");
migrationBuilder.AddForeignKey(
name: "fk_action_logs_auth_sessions_session_id",
table: "action_logs",
column: "session_id",
principalTable: "auth_sessions",
principalColumn: "id");
}
}
}

View File

@ -314,9 +314,6 @@ namespace DysonNetwork.Sphere.Migrations
b.HasIndex("AccountId") b.HasIndex("AccountId")
.HasDatabaseName("ix_action_logs_account_id"); .HasDatabaseName("ix_action_logs_account_id");
b.HasIndex("SessionId")
.HasDatabaseName("ix_action_logs_session_id");
b.ToTable("action_logs", (string)null); b.ToTable("action_logs", (string)null);
}); });
@ -2892,14 +2889,7 @@ namespace DysonNetwork.Sphere.Migrations
.IsRequired() .IsRequired()
.HasConstraintName("fk_action_logs_accounts_account_id"); .HasConstraintName("fk_action_logs_accounts_account_id");
b.HasOne("DysonNetwork.Sphere.Auth.Session", "Session")
.WithMany()
.HasForeignKey("SessionId")
.HasConstraintName("fk_action_logs_auth_sessions_session_id");
b.Navigation("Account"); b.Navigation("Account");
b.Navigation("Session");
}); });
modelBuilder.Entity("DysonNetwork.Sphere.Account.Badge", b => modelBuilder.Entity("DysonNetwork.Sphere.Account.Badge", b =>