mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-05 12:51:27 +00:00
parent
e51d35df44
commit
8b8c5b256c
3 changed files with 73 additions and 2 deletions
|
@ -0,0 +1,57 @@
|
|||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ProjectLighthouse.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20220413192851_AddUserForeignKeyToLastContacts")]
|
||||
public partial class AddUserForeignKeyToLastContacts : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// We have to delete the previous last contact information here, since we cannot guarantee that it exists.
|
||||
// There's no reliance on this information for long-term usage anyways.
|
||||
// See https://github.com/LBPUnion/ProjectLighthouse/issues/247 for more information
|
||||
migrationBuilder.Sql("DELETE FROM LastContacts;");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "UserId",
|
||||
table: "LastContacts",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int")
|
||||
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_LastContacts_Users_UserId",
|
||||
table: "LastContacts",
|
||||
column: "UserId",
|
||||
principalTable: "Users",
|
||||
principalColumn: "UserId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_LastContacts_Users_UserId",
|
||||
table: "LastContacts");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "UserId",
|
||||
table: "LastContacts",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int")
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace ProjectLighthouse.Migrations
|
|||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.3")
|
||||
.HasAnnotation("ProductVersion", "6.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.AuthenticationAttempt", b =>
|
||||
|
@ -493,7 +493,6 @@ namespace ProjectLighthouse.Migrations
|
|||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastContact", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GameVersion")
|
||||
|
@ -989,6 +988,17 @@ namespace ProjectLighthouse.Migrations
|
|||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastContact", b =>
|
||||
{
|
||||
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reports.GriefReport", b =>
|
||||
{
|
||||
b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "ReportingPlayer")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
|
||||
|
@ -7,6 +8,9 @@ public class LastContact
|
|||
[Key]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(UserId))]
|
||||
public User User { get; set; }
|
||||
|
||||
public long Timestamp { get; set; }
|
||||
|
||||
public GameVersion GameVersion { get; set; } = GameVersion.Unknown;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue