revert nullable `ToVikingId`

This commit is contained in:
Alan Moon 2025-03-06 11:49:59 -08:00
parent 6c31296d3b
commit c8c70b220e
4 changed files with 37 additions and 1411 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +0,0 @@
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

@ -33,7 +33,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingsId"); b.HasIndex("VikingsId");
b.ToTable("GroupViking"); b.ToTable("GroupViking", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.AchievementPoints", b => modelBuilder.Entity("sodoff.Model.AchievementPoints", b =>
@ -49,7 +49,7 @@ namespace sodoff.Migrations
b.HasKey("VikingId", "Type"); b.HasKey("VikingId", "Type");
b.ToTable("AchievementPoints"); b.ToTable("AchievementPoints", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => modelBuilder.Entity("sodoff.Model.AchievementTaskState", b =>
@ -67,7 +67,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("AchievementTaskState"); b.ToTable("AchievementTaskState", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Buddy", b => modelBuilder.Entity("sodoff.Model.Buddy", b =>
@ -103,7 +103,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Buddies"); b.ToTable("Buddies", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Dragon", b => modelBuilder.Entity("sodoff.Model.Dragon", b =>
@ -128,7 +128,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Dragons"); b.ToTable("Dragons", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.GameData", b => modelBuilder.Entity("sodoff.Model.GameData", b =>
@ -165,7 +165,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("GameData"); b.ToTable("GameData", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.GameDataPair", b => modelBuilder.Entity("sodoff.Model.GameDataPair", b =>
@ -188,7 +188,7 @@ namespace sodoff.Migrations
b.HasIndex("GameDataId"); b.HasIndex("GameDataId");
b.ToTable("GameDataPairs"); b.ToTable("GameDataPairs", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Group", b => modelBuilder.Entity("sodoff.Model.Group", b =>
@ -221,7 +221,7 @@ namespace sodoff.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Groups"); b.ToTable("Groups", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Image", b => modelBuilder.Entity("sodoff.Model.Image", b =>
@ -245,7 +245,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Images"); b.ToTable("Images", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.InventoryItem", b => modelBuilder.Entity("sodoff.Model.InventoryItem", b =>
@ -273,7 +273,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("InventoryItems"); b.ToTable("InventoryItems", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.MMORole", b => modelBuilder.Entity("sodoff.Model.MMORole", b =>
@ -292,7 +292,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("MMORoles"); b.ToTable("MMORoles", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Message", b => modelBuilder.Entity("sodoff.Model.Message", b =>
@ -343,7 +343,7 @@ namespace sodoff.Migrations
b.Property<int>("QueueID") b.Property<int>("QueueID")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<int?>("ToVikingId") b.Property<int>("ToVikingId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<int>("VikingId") b.Property<int>("VikingId")
@ -357,7 +357,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Messages"); b.ToTable("Messages", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.MissionState", b => modelBuilder.Entity("sodoff.Model.MissionState", b =>
@ -382,7 +382,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("MissionStates"); b.ToTable("MissionStates", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Neighborhood", b => modelBuilder.Entity("sodoff.Model.Neighborhood", b =>
@ -414,7 +414,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId") b.HasIndex("VikingId")
.IsUnique(); .IsUnique();
b.ToTable("Neighborhoods"); b.ToTable("Neighborhoods", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Pair", b => modelBuilder.Entity("sodoff.Model.Pair", b =>
@ -438,7 +438,7 @@ namespace sodoff.Migrations
b.HasIndex("MasterId"); b.HasIndex("MasterId");
b.ToTable("Pairs"); b.ToTable("Pairs", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.PairData", b => modelBuilder.Entity("sodoff.Model.PairData", b =>
@ -467,7 +467,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("PairData"); b.ToTable("PairData", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Party", b => modelBuilder.Entity("sodoff.Model.Party", b =>
@ -501,7 +501,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Parties"); b.ToTable("Parties", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => modelBuilder.Entity("sodoff.Model.ProfileAnswer", b =>
@ -523,7 +523,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("ProfileAnswers"); b.ToTable("ProfileAnswers", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Rating", b => modelBuilder.Entity("sodoff.Model.Rating", b =>
@ -550,7 +550,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Ratings"); b.ToTable("Ratings", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.RatingRank", b => modelBuilder.Entity("sodoff.Model.RatingRank", b =>
@ -579,7 +579,7 @@ namespace sodoff.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("RatingRanks"); b.ToTable("RatingRanks", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Room", b => modelBuilder.Entity("sodoff.Model.Room", b =>
@ -602,7 +602,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Rooms"); b.ToTable("Rooms", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.RoomItem", b => modelBuilder.Entity("sodoff.Model.RoomItem", b =>
@ -622,7 +622,7 @@ namespace sodoff.Migrations
b.HasIndex("RoomId"); b.HasIndex("RoomId");
b.ToTable("RoomItems"); b.ToTable("RoomItems", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.SavedData", b => modelBuilder.Entity("sodoff.Model.SavedData", b =>
@ -638,7 +638,7 @@ namespace sodoff.Migrations
b.HasKey("VikingId", "SaveId"); b.HasKey("VikingId", "SaveId");
b.ToTable("SavedData"); b.ToTable("SavedData", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.SceneData", b => modelBuilder.Entity("sodoff.Model.SceneData", b =>
@ -662,7 +662,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("SceneData"); b.ToTable("SceneData", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Session", b => modelBuilder.Entity("sodoff.Model.Session", b =>
@ -686,7 +686,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Sessions"); b.ToTable("Sessions", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.TaskStatus", b => modelBuilder.Entity("sodoff.Model.TaskStatus", b =>
@ -710,7 +710,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("TaskStatuses"); b.ToTable("TaskStatuses", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.User", b => modelBuilder.Entity("sodoff.Model.User", b =>
@ -733,7 +733,7 @@ namespace sodoff.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b =>
@ -752,7 +752,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("UserBadgesCompleted"); b.ToTable("UserBadgesCompleted", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.UserBan", b => modelBuilder.Entity("sodoff.Model.UserBan", b =>
@ -777,7 +777,7 @@ namespace sodoff.Migrations
b.HasIndex("VikingId"); b.HasIndex("VikingId");
b.ToTable("Bans"); b.ToTable("Bans", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.UserMissionData", b => modelBuilder.Entity("sodoff.Model.UserMissionData", b =>
@ -802,7 +802,7 @@ namespace sodoff.Migrations
b.HasKey("VikingId", "WorldId", "MissionId"); b.HasKey("VikingId", "WorldId", "MissionId");
b.ToTable("UserMissionData"); b.ToTable("UserMissionData", (string)null);
}); });
modelBuilder.Entity("sodoff.Model.Viking", b => modelBuilder.Entity("sodoff.Model.Viking", b =>
@ -848,7 +848,7 @@ namespace sodoff.Migrations
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("Vikings"); b.ToTable("Vikings", (string)null);
}); });
modelBuilder.Entity("GroupViking", b => modelBuilder.Entity("GroupViking", b =>
@ -982,7 +982,9 @@ namespace sodoff.Migrations
b.HasOne("sodoff.Model.Viking", "ToViking") b.HasOne("sodoff.Model.Viking", "ToViking")
.WithMany("MessageBoard") .WithMany("MessageBoard")
.HasForeignKey("ToVikingId"); .HasForeignKey("ToVikingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("sodoff.Model.Viking", "Viking") b.HasOne("sodoff.Model.Viking", "Viking")
.WithMany("MessagesMade") .WithMany("MessagesMade")

View File

@ -16,14 +16,14 @@ public class MessagingService
this.ctx = ctx; this.ctx = ctx;
} }
public Model.Message AddMessageToViking(Viking viking, Viking toViking, MessageType messageType, MessageTypeID messageTypeID, MessageLevel messageLevel, string data, string memberMessage = "", string nonMemberMessage = "", bool IsNew = true, bool IsDeleted = false, bool isReply = false, bool isPrivate = false, int parentMessageId = 0) public Model.Message AddMessageToViking(Viking viking, Viking? toViking, MessageType messageType, MessageTypeID messageTypeID, MessageLevel messageLevel, string data, string memberMessage = "", string nonMemberMessage = "", bool IsNew = true, bool IsDeleted = false, bool isReply = false, bool isPrivate = false, int parentMessageId = 0)
{ {
// get execution UTC timestamp // get execution UTC timestamp
DateTime now = DateTime.UtcNow; DateTime now = DateTime.UtcNow;
// for generating ConversationId and QueueId // for generating ConversationId and QueueId
Random rnd = new Random(); Random rnd = new Random();
// construct message // construct message
Model.Message message = new Model.Message Model.Message message = new Model.Message
{ {