make `ToVikingId` nullable for system messages

This commit is contained in:
Alan Moon 2025-03-06 11:45:50 -08:00
parent b7b99cd353
commit 6c31296d3b
4 changed files with 1379 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace sodoff.Migrations
{
/// <inheritdoc />
public partial class Messaging_ToVikingIdNullable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Messages_Vikings_ToVikingId",
table: "Messages");
migrationBuilder.AlterColumn<int>(
name: "ToVikingId",
table: "Messages",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AddForeignKey(
name: "FK_Messages_Vikings_ToVikingId",
table: "Messages",
column: "ToVikingId",
principalTable: "Vikings",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Messages_Vikings_ToVikingId",
table: "Messages");
migrationBuilder.AlterColumn<int>(
name: "ToVikingId",
table: "Messages",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Messages_Vikings_ToVikingId",
table: "Messages",
column: "ToVikingId",
principalTable: "Vikings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -343,7 +343,7 @@ namespace sodoff.Migrations
b.Property<int>("QueueID")
.HasColumnType("INTEGER");
b.Property<int>("ToVikingId")
b.Property<int?>("ToVikingId")
.HasColumnType("INTEGER");
b.Property<int>("VikingId")
@ -982,9 +982,7 @@ namespace sodoff.Migrations
b.HasOne("sodoff.Model.Viking", "ToViking")
.WithMany("MessageBoard")
.HasForeignKey("ToVikingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("ToVikingId");
b.HasOne("sodoff.Model.Viking", "Viking")
.WithMany("MessagesMade")

View File

@ -10,7 +10,7 @@ public class Message
public int Id { get; set; }
public int VikingId { get; set; }
public int ToVikingId { get; set; }
public int? ToVikingId { get; set; }
public int QueueID { get; set; }
public int? ConversationID { get; set; }