From 7e406fd1b188ac1cbafb02a7a65217926dcc0576 Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Sun, 2 Mar 2025 16:21:10 -0800 Subject: [PATCH 1/5] initial data model work --- src/Model/DBContext.cs | 21 ++++++++++++++++++++ src/Model/Message.cs | 38 +++++++++++++++++++++++++++++++++++++ src/Model/Viking.cs | 2 ++ src/Schema/MessageLevel.cs | 8 ++++++++ src/Schema/MessageType.cs | 11 +++++++++++ src/Schema/MessageTypeID.cs | 28 +++++++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 src/Model/Message.cs create mode 100644 src/Schema/MessageLevel.cs create mode 100644 src/Schema/MessageType.cs create mode 100644 src/Schema/MessageTypeID.cs diff --git a/src/Model/DBContext.cs b/src/Model/DBContext.cs index bc1a0c9..52f9922 100644 --- a/src/Model/DBContext.cs +++ b/src/Model/DBContext.cs @@ -31,6 +31,7 @@ public class DBContext : DbContext { public DbSet UserMissionData { get; set; } = null!; public DbSet UserBadgesCompleted { get; set; } = null!; public DbSet Bans { get; set; } = null!; + public DbSet Messages { get; set; } = null!; private readonly IOptions config; @@ -160,6 +161,12 @@ public class DBContext : DbContext { builder.Entity().HasMany(v => v.UserBans) .WithOne(r => r.Viking); + builder.Entity().HasMany(v => v.MessageBoard) + .WithOne(r => r.ToViking); + + builder.Entity().HasMany(v => v.MessagesMade) + .WithOne(r => r.Viking); + // Dragons builder.Entity().HasOne(d => d.Viking) .WithMany(e => e.Dragons) @@ -310,5 +317,19 @@ public class DBContext : DbContext { builder.Entity().HasOne(r => r.Viking) .WithMany(e => e.UserBans) .HasForeignKey(e => e.VikingId); + + // Messages + builder.Entity().HasOne(r => r.Viking) + .WithMany(e => e.MessagesMade) + .HasForeignKey(e => e.VikingId); + + builder.Entity().HasOne(r => r.ToViking) + .WithMany(e => e.MessageBoard) + .HasForeignKey(e => e.ToVikingId); + + builder.Entity().HasMany(e => e.Replies) + .WithOne(e => e.ParentMessage) + .HasForeignKey(e => e.ParentMessageId) + .OnDelete(DeleteBehavior.Cascade); } } diff --git a/src/Model/Message.cs b/src/Model/Message.cs new file mode 100644 index 0000000..2025db8 --- /dev/null +++ b/src/Model/Message.cs @@ -0,0 +1,38 @@ +using System; +using System.ComponentModel.DataAnnotations; +using sodoff.Schema; + +namespace sodoff.Model; + +public class Message +{ + [Key] + public int Id { get; set; } + + public int VikingId { get; set; } + public int ToVikingId { get; set; } + + public int QueueID { get; set; } + public int? ConversationID { get; set; } + public int? ParentMessageId { get; set; } + + public MessageType? MessageType { get; set; } + public MessageTypeID? MessageTypeID { get; set; } + public MessageLevel MessageLevel { get; set; } + + public string? Data { get; set; } + public string? MemberMessage { get; set; } + public string? NonMemberMessage { get; set; } + + public DateTime CreatedAt { get; set; } + public DateTime? LastUpdatedAt { get; set; } + + public bool IsDeleted { get; set; } + public bool IsNew { get; set; } + + public virtual Viking? Viking { get; set; } + public virtual Viking? ToViking { get; set; } + + public virtual Message? ParentMessage { get; set; } + public virtual ICollection Replies { get; set; } = null!; +} diff --git a/src/Model/Viking.cs b/src/Model/Viking.cs index 0578525..28ce7df 100644 --- a/src/Model/Viking.cs +++ b/src/Model/Viking.cs @@ -45,6 +45,8 @@ public class Viking { public virtual ICollection UserMissions { get; set; } = null!; public virtual ICollection UserBadgesCompleted { get; set; } = null!; public virtual ICollection UserBans { get; set; } = null!; + public virtual ICollection MessageBoard { get; set; } = null!; + public virtual ICollection MessagesMade { get; set; } = null!; public DateTime? CreationDate { get; set; } public DateTime? BirthDate { get; set; } diff --git a/src/Schema/MessageLevel.cs b/src/Schema/MessageLevel.cs new file mode 100644 index 0000000..b4cf30a --- /dev/null +++ b/src/Schema/MessageLevel.cs @@ -0,0 +1,8 @@ +namespace sodoff.Schema +{ + public enum MessageLevel + { + Canned = 1, + WhiteList + } +} \ No newline at end of file diff --git a/src/Schema/MessageType.cs b/src/Schema/MessageType.cs new file mode 100644 index 0000000..6f8291b --- /dev/null +++ b/src/Schema/MessageType.cs @@ -0,0 +1,11 @@ +namespace sodoff.Schema +{ + public enum MessageType + { + Chat = 1, + Post = 2, + Data = 3, + Challenge = 4, + Announcement = 5 + } +} \ No newline at end of file diff --git a/src/Schema/MessageTypeID.cs b/src/Schema/MessageTypeID.cs new file mode 100644 index 0000000..5bf8d79 --- /dev/null +++ b/src/Schema/MessageTypeID.cs @@ -0,0 +1,28 @@ +namespace sodoff.Schema +{ + public enum MessageTypeID + { + Unknown = 0, + Billboard = 1, + Dialog = 2, + Notification = 3, + Rank = 4, + BuddyList = 5, + Jumpstar = 6, + SpaAdventureGift = 7, + PrizeCode = 8, + Achievement = 9, + Messaging = 10, + SocialRank = 11, + MuttCare = 12, + Mission = 13, + ChallengeWon = 14, + InviteFriend = 15, + Gifts = 19, + FriendReward = 20, + ThreadUpdate = 21, + Photo = 22, + GreetingCard = 23, + ProfileSelection = 24 + } +} \ No newline at end of file -- 2.47.2 From 1ca53d580ff519215729a30eda331504dcf45eb3 Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Sun, 2 Mar 2025 16:29:25 -0800 Subject: [PATCH 2/5] reference ``Microsoft.EntityFrameworkCore.Design`` for database version control add initial migration --- ...3002741_IntialCreatePostDesign.Designer.cs | 1257 +++++++++++++++++ .../20250303002741_IntialCreatePostDesign.cs | 971 +++++++++++++ src/Migrations/DBContextModelSnapshot.cs | 1254 ++++++++++++++++ src/sodoff.csproj | 4 + 4 files changed, 3486 insertions(+) create mode 100644 src/Migrations/20250303002741_IntialCreatePostDesign.Designer.cs create mode 100644 src/Migrations/20250303002741_IntialCreatePostDesign.cs create mode 100644 src/Migrations/DBContextModelSnapshot.cs diff --git a/src/Migrations/20250303002741_IntialCreatePostDesign.Designer.cs b/src/Migrations/20250303002741_IntialCreatePostDesign.Designer.cs new file mode 100644 index 0000000..dd4113d --- /dev/null +++ b/src/Migrations/20250303002741_IntialCreatePostDesign.Designer.cs @@ -0,0 +1,1257 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using sodoff.Model; + +#nullable disable + +namespace sodoff.Migrations +{ + [DbContext(typeof(DBContext))] + [Migration("20250303002741_IntialCreatePostDesign")] + partial class IntialCreatePostDesign + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true); + + modelBuilder.Entity("GroupViking", b => + { + b.Property("GroupsId") + .HasColumnType("INTEGER"); + + b.Property("VikingsId") + .HasColumnType("INTEGER"); + + b.HasKey("GroupsId", "VikingsId"); + + b.HasIndex("VikingsId"); + + b.ToTable("GroupViking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "Type"); + + b.ToTable("AchievementPoints"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Points") + .HasColumnType("INTEGER"); + + b.HasKey("TaskId", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("AchievementTaskState"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EntityId") + .HasColumnType("TEXT"); + + b.Property("PetXP") + .HasColumnType("INTEGER"); + + b.Property("RaisedPetData") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Dragons"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DatePlayed") + .HasColumnType("TEXT"); + + b.Property("Difficulty") + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("GameLevel") + .HasColumnType("INTEGER"); + + b.Property("IsMultiplayer") + .HasColumnType("INTEGER"); + + b.Property("Loss") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Win") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDataId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GameDataId"); + + b.ToTable("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApiKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Color") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GroupID") + .HasColumnType("TEXT"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.Property("ImageType") + .HasColumnType("TEXT"); + + b.Property("ImageSlot") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("ImageData") + .HasColumnType("TEXT"); + + b.Property("TemplateName") + .HasColumnType("TEXT"); + + b.HasKey("ImageType", "ImageSlot", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AttributesSerialized") + .HasColumnType("TEXT"); + + b.Property("ItemId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.Property("StatsSerialized") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("InventoryItems"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MMORoles"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConversationID") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("IsDeleted") + .HasColumnType("INTEGER"); + + b.Property("IsNew") + .HasColumnType("INTEGER"); + + b.Property("LastUpdatedAt") + .HasColumnType("TEXT"); + + b.Property("MemberMessage") + .HasColumnType("TEXT"); + + b.Property("MessageLevel") + .HasColumnType("INTEGER"); + + b.Property("MessageType") + .HasColumnType("INTEGER"); + + b.Property("MessageTypeID") + .HasColumnType("INTEGER"); + + b.Property("NonMemberMessage") + .HasColumnType("TEXT"); + + b.Property("ParentMessageId") + .HasColumnType("INTEGER"); + + b.Property("QueueID") + .HasColumnType("INTEGER"); + + b.Property("ToVikingId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ParentMessageId"); + + b.HasIndex("ToVikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("MissionStatus") + .HasColumnType("INTEGER"); + + b.Property("UserAccepted") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MissionStates"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Slot0") + .HasColumnType("TEXT"); + + b.Property("Slot1") + .HasColumnType("TEXT"); + + b.Property("Slot2") + .HasColumnType("TEXT"); + + b.Property("Slot3") + .HasColumnType("TEXT"); + + b.Property("Slot4") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId") + .IsUnique(); + + b.ToTable("Neighborhoods"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MasterId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MasterId"); + + b.ToTable("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DragonId") + .HasColumnType("INTEGER"); + + b.Property("PairId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DragonId"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssetBundle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("Location") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LocationIconAsset") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PrivateParty") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Parties"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AnswerID") + .HasColumnType("INTEGER"); + + b.Property("QuestionID") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("ProfileAnswers"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("RankId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RankId"); + + b.HasIndex("VikingId"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryID") + .HasColumnType("INTEGER"); + + b.Property("Rank") + .HasColumnType("INTEGER"); + + b.Property("RatedEntityID") + .HasColumnType("INTEGER"); + + b.Property("RatedUserID") + .HasColumnType("TEXT"); + + b.Property("RatingAverage") + .HasColumnType("REAL"); + + b.Property("UpdateDate") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("RatingRanks"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("RoomId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Rooms"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RoomId") + .HasColumnType("INTEGER"); + + b.Property("RoomItemData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoomId"); + + b.ToTable("RoomItems"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("SaveId") + .HasColumnType("INTEGER"); + + b.Property("SerializedData") + .HasColumnType("TEXT"); + + b.HasKey("VikingId", "SaveId"); + + b.ToTable("SavedData"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("SceneName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("XmlData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("SceneData"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.Property("ApiToken") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("ApiToken"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("Completed") + .HasColumnType("INTEGER"); + + b.Property("Payload") + .HasColumnType("TEXT"); + + b.HasKey("Id", "VikingId", "MissionId"); + + b.HasIndex("VikingId"); + + b.ToTable("TaskStatuses"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BadgeId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("UserBadgesCompleted"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("UserBanType") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("WorldId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("IsCompleted") + .HasColumnType("INTEGER"); + + b.Property("StepId") + .HasColumnType("INTEGER"); + + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "WorldId", "MissionId"); + + b.ToTable("UserMissionData"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvatarSerialized") + .HasColumnType("TEXT"); + + b.Property("BirthDate") + .HasColumnType("TEXT"); + + b.Property("CreationDate") + .HasColumnType("TEXT"); + + b.Property("GameVersion") + .HasColumnType("INTEGER"); + + b.Property("Gender") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SelectedDragonId") + .HasColumnType("INTEGER"); + + b.Property("Uid") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SelectedDragonId") + .IsUnique(); + + b.HasIndex("Uid"); + + b.HasIndex("UserId"); + + b.ToTable("Vikings"); + }); + + modelBuilder.Entity("GroupViking", b => + { + b.HasOne("sodoff.Model.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", null) + .WithMany() + .HasForeignKey("VikingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementPoints") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementTaskStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Dragons") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("GameData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.HasOne("sodoff.Model.GameData", "GameData") + .WithMany("GameDataPairs") + .HasForeignKey("GameDataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Images") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("InventoryItems") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MMORoles") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.HasOne("sodoff.Model.Message", "ParentMessage") + .WithMany("Replies") + .HasForeignKey("ParentMessageId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "ToViking") + .WithMany("MessageBoard") + .HasForeignKey("ToVikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MessagesMade") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ParentMessage"); + + b.Navigation("ToViking"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MissionStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithOne("Neighborhood") + .HasForeignKey("sodoff.Model.Neighborhood", "VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.HasOne("sodoff.Model.PairData", "PairData") + .WithMany("Pairs") + .HasForeignKey("MasterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.HasOne("sodoff.Model.Dragon", "Dragon") + .WithMany("PairData") + .HasForeignKey("DragonId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("PairData") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("PairData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Dragon"); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Parties") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("ProfileAnswers") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.HasOne("sodoff.Model.RatingRank", "Rank") + .WithMany("Ratings") + .HasForeignKey("RankId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Ratings") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Rank"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Rooms") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.HasOne("sodoff.Model.Room", "Room") + .WithMany("Items") + .HasForeignKey("RoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Room"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SavedData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SceneData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.HasOne("sodoff.Model.User", "User") + .WithMany("Sessions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Sessions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("TaskStatuses") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBadgesCompleted") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBans") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserMissions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.HasOne("sodoff.Model.Dragon", "SelectedDragon") + .WithOne() + .HasForeignKey("sodoff.Model.Viking", "SelectedDragonId"); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("Vikings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SelectedDragon"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Navigation("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Navigation("Replies"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Navigation("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Navigation("PairData"); + + b.Navigation("Sessions"); + + b.Navigation("Vikings"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Navigation("AchievementPoints"); + + b.Navigation("AchievementTaskStates"); + + b.Navigation("Dragons"); + + b.Navigation("GameData"); + + b.Navigation("Images"); + + b.Navigation("InventoryItems"); + + b.Navigation("MMORoles"); + + b.Navigation("MessageBoard"); + + b.Navigation("MessagesMade"); + + b.Navigation("MissionStates"); + + b.Navigation("Neighborhood"); + + b.Navigation("PairData"); + + b.Navigation("Parties"); + + b.Navigation("ProfileAnswers"); + + b.Navigation("Ratings"); + + b.Navigation("Rooms"); + + b.Navigation("SavedData"); + + b.Navigation("SceneData"); + + b.Navigation("Sessions"); + + b.Navigation("TaskStatuses"); + + b.Navigation("UserBadgesCompleted"); + + b.Navigation("UserBans"); + + b.Navigation("UserMissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20250303002741_IntialCreatePostDesign.cs b/src/Migrations/20250303002741_IntialCreatePostDesign.cs new file mode 100644 index 0000000..4f50e5e --- /dev/null +++ b/src/Migrations/20250303002741_IntialCreatePostDesign.cs @@ -0,0 +1,971 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace sodoff.Migrations +{ + /// + public partial class IntialCreatePostDesign : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Groups", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GroupID = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + Type = table.Column(type: "INTEGER", nullable: false), + Color = table.Column(type: "TEXT", nullable: false), + Logo = table.Column(type: "TEXT", nullable: false), + ApiKey = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "RatingRanks", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + CategoryID = table.Column(type: "INTEGER", nullable: false), + RatedEntityID = table.Column(type: "INTEGER", nullable: true), + RatedUserID = table.Column(type: "TEXT", nullable: true), + Rank = table.Column(type: "INTEGER", nullable: false), + RatingAverage = table.Column(type: "REAL", nullable: false), + UpdateDate = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RatingRanks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Email = table.Column(type: "TEXT", nullable: false), + Username = table.Column(type: "TEXT", nullable: false), + Password = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AchievementPoints", + columns: table => new + { + VikingId = table.Column(type: "INTEGER", nullable: false), + Type = table.Column(type: "INTEGER", nullable: false), + Value = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AchievementPoints", x => new { x.VikingId, x.Type }); + }); + + migrationBuilder.CreateTable( + name: "AchievementTaskState", + columns: table => new + { + VikingId = table.Column(type: "INTEGER", nullable: false), + TaskId = table.Column(type: "INTEGER", nullable: false), + Points = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AchievementTaskState", x => new { x.TaskId, x.VikingId }); + }); + + migrationBuilder.CreateTable( + name: "Bans", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + UserBanType = table.Column(type: "INTEGER", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + ExpiresOn = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Bans", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Dragons", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + EntityId = table.Column(type: "TEXT", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + RaisedPetData = table.Column(type: "TEXT", nullable: true), + PetXP = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Dragons", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Vikings", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Uid = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + UserId = table.Column(type: "TEXT", nullable: false), + AvatarSerialized = table.Column(type: "TEXT", nullable: true), + SelectedDragonId = table.Column(type: "INTEGER", nullable: true), + CreationDate = table.Column(type: "TEXT", nullable: true), + BirthDate = table.Column(type: "TEXT", nullable: true), + Gender = table.Column(type: "INTEGER", nullable: true), + GameVersion = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Vikings", x => x.Id); + table.ForeignKey( + name: "FK_Vikings_Dragons_SelectedDragonId", + column: x => x.SelectedDragonId, + principalTable: "Dragons", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Vikings_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GameData", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + GameId = table.Column(type: "INTEGER", nullable: false), + Difficulty = table.Column(type: "INTEGER", nullable: false), + GameLevel = table.Column(type: "INTEGER", nullable: false), + DatePlayed = table.Column(type: "TEXT", nullable: false), + IsMultiplayer = table.Column(type: "INTEGER", nullable: false), + Win = table.Column(type: "INTEGER", nullable: false), + Loss = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GameData", x => x.Id); + table.ForeignKey( + name: "FK_GameData_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupViking", + columns: table => new + { + GroupsId = table.Column(type: "INTEGER", nullable: false), + VikingsId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupViking", x => new { x.GroupsId, x.VikingsId }); + table.ForeignKey( + name: "FK_GroupViking_Groups_GroupsId", + column: x => x.GroupsId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupViking_Vikings_VikingsId", + column: x => x.VikingsId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Images", + columns: table => new + { + ImageType = table.Column(type: "TEXT", nullable: false), + ImageSlot = table.Column(type: "INTEGER", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + ImageData = table.Column(type: "TEXT", nullable: true), + TemplateName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Images", x => new { x.ImageType, x.ImageSlot, x.VikingId }); + table.ForeignKey( + name: "FK_Images_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "InventoryItems", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ItemId = table.Column(type: "INTEGER", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + StatsSerialized = table.Column(type: "TEXT", nullable: true), + AttributesSerialized = table.Column(type: "TEXT", nullable: true), + Quantity = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InventoryItems", x => x.Id); + table.ForeignKey( + name: "FK_InventoryItems_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Messages", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + ToVikingId = table.Column(type: "INTEGER", nullable: false), + QueueID = table.Column(type: "INTEGER", nullable: false), + ConversationID = table.Column(type: "INTEGER", nullable: true), + ParentMessageId = table.Column(type: "INTEGER", nullable: true), + MessageType = table.Column(type: "INTEGER", nullable: true), + MessageTypeID = table.Column(type: "INTEGER", nullable: true), + MessageLevel = table.Column(type: "INTEGER", nullable: false), + Data = table.Column(type: "TEXT", nullable: true), + MemberMessage = table.Column(type: "TEXT", nullable: true), + NonMemberMessage = table.Column(type: "TEXT", nullable: true), + CreatedAt = table.Column(type: "TEXT", nullable: false), + LastUpdatedAt = table.Column(type: "TEXT", nullable: true), + IsDeleted = table.Column(type: "INTEGER", nullable: false), + IsNew = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Messages", x => x.Id); + table.ForeignKey( + name: "FK_Messages_Messages_ParentMessageId", + column: x => x.ParentMessageId, + principalTable: "Messages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Messages_Vikings_ToVikingId", + column: x => x.ToVikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Messages_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionStates", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + MissionId = table.Column(type: "INTEGER", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + MissionStatus = table.Column(type: "INTEGER", nullable: false), + UserAccepted = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionStates", x => x.Id); + table.ForeignKey( + name: "FK_MissionStates_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MMORoles", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + Role = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MMORoles", x => x.Id); + table.ForeignKey( + name: "FK_MMORoles_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Neighborhoods", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + Slot0 = table.Column(type: "TEXT", nullable: false), + Slot1 = table.Column(type: "TEXT", nullable: false), + Slot2 = table.Column(type: "TEXT", nullable: false), + Slot3 = table.Column(type: "TEXT", nullable: false), + Slot4 = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Neighborhoods", x => x.Id); + table.ForeignKey( + name: "FK_Neighborhoods_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PairData", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + PairId = table.Column(type: "INTEGER", nullable: false), + UserId = table.Column(type: "TEXT", nullable: true), + VikingId = table.Column(type: "INTEGER", nullable: true), + DragonId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PairData", x => x.Id); + table.ForeignKey( + name: "FK_PairData_Dragons_DragonId", + column: x => x.DragonId, + principalTable: "Dragons", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PairData_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PairData_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Parties", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Location = table.Column(type: "TEXT", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + ExpirationDate = table.Column(type: "TEXT", nullable: false), + PrivateParty = table.Column(type: "INTEGER", nullable: true), + LocationIconAsset = table.Column(type: "TEXT", nullable: false), + AssetBundle = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Parties", x => x.Id); + table.ForeignKey( + name: "FK_Parties_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProfileAnswers", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + QuestionID = table.Column(type: "INTEGER", nullable: false), + AnswerID = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProfileAnswers", x => x.Id); + table.ForeignKey( + name: "FK_ProfileAnswers_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Ratings", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + RankId = table.Column(type: "INTEGER", nullable: false), + Value = table.Column(type: "INTEGER", nullable: false), + Date = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Ratings", x => x.Id); + table.ForeignKey( + name: "FK_Ratings_RatingRanks_RankId", + column: x => x.RankId, + principalTable: "RatingRanks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Ratings_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Rooms", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + RoomId = table.Column(type: "TEXT", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Rooms", x => x.Id); + table.ForeignKey( + name: "FK_Rooms_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SavedData", + columns: table => new + { + VikingId = table.Column(type: "INTEGER", nullable: false), + SaveId = table.Column(type: "INTEGER", nullable: false), + SerializedData = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SavedData", x => new { x.VikingId, x.SaveId }); + table.ForeignKey( + name: "FK_SavedData_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SceneData", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + SceneName = table.Column(type: "TEXT", nullable: false), + XmlData = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SceneData", x => x.Id); + table.ForeignKey( + name: "FK_SceneData_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Sessions", + columns: table => new + { + ApiToken = table.Column(type: "TEXT", nullable: false), + UserId = table.Column(type: "TEXT", nullable: true), + VikingId = table.Column(type: "INTEGER", nullable: true), + CreatedAt = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Sessions", x => x.ApiToken); + table.ForeignKey( + name: "FK_Sessions_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Sessions_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TaskStatuses", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false), + MissionId = table.Column(type: "INTEGER", nullable: false), + VikingId = table.Column(type: "INTEGER", nullable: false), + Payload = table.Column(type: "TEXT", nullable: true), + Completed = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskStatuses", x => new { x.Id, x.VikingId, x.MissionId }); + table.ForeignKey( + name: "FK_TaskStatuses_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserBadgesCompleted", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + VikingId = table.Column(type: "INTEGER", nullable: false), + BadgeId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserBadgesCompleted", x => x.Id); + table.ForeignKey( + name: "FK_UserBadgesCompleted_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserMissionData", + columns: table => new + { + VikingId = table.Column(type: "INTEGER", nullable: false), + WorldId = table.Column(type: "INTEGER", nullable: false), + MissionId = table.Column(type: "INTEGER", nullable: false), + StepId = table.Column(type: "INTEGER", nullable: false), + TaskId = table.Column(type: "INTEGER", nullable: false), + IsCompleted = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserMissionData", x => new { x.VikingId, x.WorldId, x.MissionId }); + table.ForeignKey( + name: "FK_UserMissionData_Vikings_VikingId", + column: x => x.VikingId, + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GameDataPairs", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GameDataId = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + Value = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GameDataPairs", x => x.Id); + table.ForeignKey( + name: "FK_GameDataPairs_GameData_GameDataId", + column: x => x.GameDataId, + principalTable: "GameData", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Pairs", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Key = table.Column(type: "TEXT", nullable: false), + Value = table.Column(type: "TEXT", nullable: false), + MasterId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Pairs", x => x.Id); + table.ForeignKey( + name: "FK_Pairs_PairData_MasterId", + column: x => x.MasterId, + principalTable: "PairData", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoomItems", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + RoomId = table.Column(type: "INTEGER", nullable: false), + RoomItemData = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoomItems", x => x.Id); + table.ForeignKey( + name: "FK_RoomItems_Rooms_RoomId", + column: x => x.RoomId, + principalTable: "Rooms", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AchievementTaskState_VikingId", + table: "AchievementTaskState", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Bans_VikingId", + table: "Bans", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Dragons_VikingId", + table: "Dragons", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_GameData_VikingId", + table: "GameData", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_GameDataPairs_GameDataId", + table: "GameDataPairs", + column: "GameDataId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupViking_VikingsId", + table: "GroupViking", + column: "VikingsId"); + + migrationBuilder.CreateIndex( + name: "IX_Images_VikingId", + table: "Images", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_InventoryItems_VikingId", + table: "InventoryItems", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Messages_ParentMessageId", + table: "Messages", + column: "ParentMessageId"); + + migrationBuilder.CreateIndex( + name: "IX_Messages_ToVikingId", + table: "Messages", + column: "ToVikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Messages_VikingId", + table: "Messages", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_MissionStates_VikingId", + table: "MissionStates", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_MMORoles_VikingId", + table: "MMORoles", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Neighborhoods_VikingId", + table: "Neighborhoods", + column: "VikingId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_PairData_DragonId", + table: "PairData", + column: "DragonId"); + + migrationBuilder.CreateIndex( + name: "IX_PairData_UserId", + table: "PairData", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_PairData_VikingId", + table: "PairData", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Pairs_MasterId", + table: "Pairs", + column: "MasterId"); + + migrationBuilder.CreateIndex( + name: "IX_Parties_VikingId", + table: "Parties", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_ProfileAnswers_VikingId", + table: "ProfileAnswers", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Ratings_RankId", + table: "Ratings", + column: "RankId"); + + migrationBuilder.CreateIndex( + name: "IX_Ratings_VikingId", + table: "Ratings", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_RoomItems_RoomId", + table: "RoomItems", + column: "RoomId"); + + migrationBuilder.CreateIndex( + name: "IX_Rooms_VikingId", + table: "Rooms", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_SceneData_VikingId", + table: "SceneData", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Sessions_UserId", + table: "Sessions", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Sessions_VikingId", + table: "Sessions", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_TaskStatuses_VikingId", + table: "TaskStatuses", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_UserBadgesCompleted_VikingId", + table: "UserBadgesCompleted", + column: "VikingId"); + + migrationBuilder.CreateIndex( + name: "IX_Vikings_SelectedDragonId", + table: "Vikings", + column: "SelectedDragonId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Vikings_Uid", + table: "Vikings", + column: "Uid"); + + migrationBuilder.CreateIndex( + name: "IX_Vikings_UserId", + table: "Vikings", + column: "UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_AchievementPoints_Vikings_VikingId", + table: "AchievementPoints", + column: "VikingId", + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AchievementTaskState_Vikings_VikingId", + table: "AchievementTaskState", + column: "VikingId", + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Bans_Vikings_VikingId", + table: "Bans", + column: "VikingId", + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Dragons_Vikings_VikingId", + table: "Dragons", + column: "VikingId", + principalTable: "Vikings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Dragons_Vikings_VikingId", + table: "Dragons"); + + migrationBuilder.DropTable( + name: "AchievementPoints"); + + migrationBuilder.DropTable( + name: "AchievementTaskState"); + + migrationBuilder.DropTable( + name: "Bans"); + + migrationBuilder.DropTable( + name: "GameDataPairs"); + + migrationBuilder.DropTable( + name: "GroupViking"); + + migrationBuilder.DropTable( + name: "Images"); + + migrationBuilder.DropTable( + name: "InventoryItems"); + + migrationBuilder.DropTable( + name: "Messages"); + + migrationBuilder.DropTable( + name: "MissionStates"); + + migrationBuilder.DropTable( + name: "MMORoles"); + + migrationBuilder.DropTable( + name: "Neighborhoods"); + + migrationBuilder.DropTable( + name: "Pairs"); + + migrationBuilder.DropTable( + name: "Parties"); + + migrationBuilder.DropTable( + name: "ProfileAnswers"); + + migrationBuilder.DropTable( + name: "Ratings"); + + migrationBuilder.DropTable( + name: "RoomItems"); + + migrationBuilder.DropTable( + name: "SavedData"); + + migrationBuilder.DropTable( + name: "SceneData"); + + migrationBuilder.DropTable( + name: "Sessions"); + + migrationBuilder.DropTable( + name: "TaskStatuses"); + + migrationBuilder.DropTable( + name: "UserBadgesCompleted"); + + migrationBuilder.DropTable( + name: "UserMissionData"); + + migrationBuilder.DropTable( + name: "GameData"); + + migrationBuilder.DropTable( + name: "Groups"); + + migrationBuilder.DropTable( + name: "PairData"); + + migrationBuilder.DropTable( + name: "RatingRanks"); + + migrationBuilder.DropTable( + name: "Rooms"); + + migrationBuilder.DropTable( + name: "Vikings"); + + migrationBuilder.DropTable( + name: "Dragons"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/src/Migrations/DBContextModelSnapshot.cs b/src/Migrations/DBContextModelSnapshot.cs new file mode 100644 index 0000000..07798dd --- /dev/null +++ b/src/Migrations/DBContextModelSnapshot.cs @@ -0,0 +1,1254 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using sodoff.Model; + +#nullable disable + +namespace sodoff.Migrations +{ + [DbContext(typeof(DBContext))] + partial class DBContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true); + + modelBuilder.Entity("GroupViking", b => + { + b.Property("GroupsId") + .HasColumnType("INTEGER"); + + b.Property("VikingsId") + .HasColumnType("INTEGER"); + + b.HasKey("GroupsId", "VikingsId"); + + b.HasIndex("VikingsId"); + + b.ToTable("GroupViking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "Type"); + + b.ToTable("AchievementPoints"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Points") + .HasColumnType("INTEGER"); + + b.HasKey("TaskId", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("AchievementTaskState"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EntityId") + .HasColumnType("TEXT"); + + b.Property("PetXP") + .HasColumnType("INTEGER"); + + b.Property("RaisedPetData") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Dragons"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DatePlayed") + .HasColumnType("TEXT"); + + b.Property("Difficulty") + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("GameLevel") + .HasColumnType("INTEGER"); + + b.Property("IsMultiplayer") + .HasColumnType("INTEGER"); + + b.Property("Loss") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Win") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDataId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GameDataId"); + + b.ToTable("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApiKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Color") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GroupID") + .HasColumnType("TEXT"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.Property("ImageType") + .HasColumnType("TEXT"); + + b.Property("ImageSlot") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("ImageData") + .HasColumnType("TEXT"); + + b.Property("TemplateName") + .HasColumnType("TEXT"); + + b.HasKey("ImageType", "ImageSlot", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AttributesSerialized") + .HasColumnType("TEXT"); + + b.Property("ItemId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.Property("StatsSerialized") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("InventoryItems"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MMORoles"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConversationID") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("IsDeleted") + .HasColumnType("INTEGER"); + + b.Property("IsNew") + .HasColumnType("INTEGER"); + + b.Property("LastUpdatedAt") + .HasColumnType("TEXT"); + + b.Property("MemberMessage") + .HasColumnType("TEXT"); + + b.Property("MessageLevel") + .HasColumnType("INTEGER"); + + b.Property("MessageType") + .HasColumnType("INTEGER"); + + b.Property("MessageTypeID") + .HasColumnType("INTEGER"); + + b.Property("NonMemberMessage") + .HasColumnType("TEXT"); + + b.Property("ParentMessageId") + .HasColumnType("INTEGER"); + + b.Property("QueueID") + .HasColumnType("INTEGER"); + + b.Property("ToVikingId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ParentMessageId"); + + b.HasIndex("ToVikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("MissionStatus") + .HasColumnType("INTEGER"); + + b.Property("UserAccepted") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MissionStates"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Slot0") + .HasColumnType("TEXT"); + + b.Property("Slot1") + .HasColumnType("TEXT"); + + b.Property("Slot2") + .HasColumnType("TEXT"); + + b.Property("Slot3") + .HasColumnType("TEXT"); + + b.Property("Slot4") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId") + .IsUnique(); + + b.ToTable("Neighborhoods"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MasterId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MasterId"); + + b.ToTable("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DragonId") + .HasColumnType("INTEGER"); + + b.Property("PairId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DragonId"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssetBundle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("Location") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LocationIconAsset") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PrivateParty") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Parties"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AnswerID") + .HasColumnType("INTEGER"); + + b.Property("QuestionID") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("ProfileAnswers"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("RankId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RankId"); + + b.HasIndex("VikingId"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryID") + .HasColumnType("INTEGER"); + + b.Property("Rank") + .HasColumnType("INTEGER"); + + b.Property("RatedEntityID") + .HasColumnType("INTEGER"); + + b.Property("RatedUserID") + .HasColumnType("TEXT"); + + b.Property("RatingAverage") + .HasColumnType("REAL"); + + b.Property("UpdateDate") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("RatingRanks"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("RoomId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Rooms"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RoomId") + .HasColumnType("INTEGER"); + + b.Property("RoomItemData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoomId"); + + b.ToTable("RoomItems"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("SaveId") + .HasColumnType("INTEGER"); + + b.Property("SerializedData") + .HasColumnType("TEXT"); + + b.HasKey("VikingId", "SaveId"); + + b.ToTable("SavedData"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("SceneName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("XmlData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("SceneData"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.Property("ApiToken") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("ApiToken"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("Completed") + .HasColumnType("INTEGER"); + + b.Property("Payload") + .HasColumnType("TEXT"); + + b.HasKey("Id", "VikingId", "MissionId"); + + b.HasIndex("VikingId"); + + b.ToTable("TaskStatuses"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BadgeId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("UserBadgesCompleted"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("UserBanType") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("WorldId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("IsCompleted") + .HasColumnType("INTEGER"); + + b.Property("StepId") + .HasColumnType("INTEGER"); + + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "WorldId", "MissionId"); + + b.ToTable("UserMissionData"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvatarSerialized") + .HasColumnType("TEXT"); + + b.Property("BirthDate") + .HasColumnType("TEXT"); + + b.Property("CreationDate") + .HasColumnType("TEXT"); + + b.Property("GameVersion") + .HasColumnType("INTEGER"); + + b.Property("Gender") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SelectedDragonId") + .HasColumnType("INTEGER"); + + b.Property("Uid") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SelectedDragonId") + .IsUnique(); + + b.HasIndex("Uid"); + + b.HasIndex("UserId"); + + b.ToTable("Vikings"); + }); + + modelBuilder.Entity("GroupViking", b => + { + b.HasOne("sodoff.Model.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", null) + .WithMany() + .HasForeignKey("VikingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementPoints") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementTaskStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Dragons") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("GameData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.HasOne("sodoff.Model.GameData", "GameData") + .WithMany("GameDataPairs") + .HasForeignKey("GameDataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Images") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("InventoryItems") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MMORoles") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.HasOne("sodoff.Model.Message", "ParentMessage") + .WithMany("Replies") + .HasForeignKey("ParentMessageId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "ToViking") + .WithMany("MessageBoard") + .HasForeignKey("ToVikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MessagesMade") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ParentMessage"); + + b.Navigation("ToViking"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MissionStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithOne("Neighborhood") + .HasForeignKey("sodoff.Model.Neighborhood", "VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.HasOne("sodoff.Model.PairData", "PairData") + .WithMany("Pairs") + .HasForeignKey("MasterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.HasOne("sodoff.Model.Dragon", "Dragon") + .WithMany("PairData") + .HasForeignKey("DragonId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("PairData") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("PairData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Dragon"); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Parties") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("ProfileAnswers") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.HasOne("sodoff.Model.RatingRank", "Rank") + .WithMany("Ratings") + .HasForeignKey("RankId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Ratings") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Rank"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Rooms") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.HasOne("sodoff.Model.Room", "Room") + .WithMany("Items") + .HasForeignKey("RoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Room"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SavedData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SceneData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.HasOne("sodoff.Model.User", "User") + .WithMany("Sessions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Sessions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("TaskStatuses") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBadgesCompleted") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBans") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserMissions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.HasOne("sodoff.Model.Dragon", "SelectedDragon") + .WithOne() + .HasForeignKey("sodoff.Model.Viking", "SelectedDragonId"); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("Vikings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SelectedDragon"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Navigation("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Navigation("Replies"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Navigation("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Navigation("PairData"); + + b.Navigation("Sessions"); + + b.Navigation("Vikings"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Navigation("AchievementPoints"); + + b.Navigation("AchievementTaskStates"); + + b.Navigation("Dragons"); + + b.Navigation("GameData"); + + b.Navigation("Images"); + + b.Navigation("InventoryItems"); + + b.Navigation("MMORoles"); + + b.Navigation("MessageBoard"); + + b.Navigation("MessagesMade"); + + b.Navigation("MissionStates"); + + b.Navigation("Neighborhood"); + + b.Navigation("PairData"); + + b.Navigation("Parties"); + + b.Navigation("ProfileAnswers"); + + b.Navigation("Ratings"); + + b.Navigation("Rooms"); + + b.Navigation("SavedData"); + + b.Navigation("SceneData"); + + b.Navigation("Sessions"); + + b.Navigation("TaskStatuses"); + + b.Navigation("UserBadgesCompleted"); + + b.Navigation("UserBans"); + + b.Navigation("UserMissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/sodoff.csproj b/src/sodoff.csproj index b8fe201..9af53c7 100644 --- a/src/sodoff.csproj +++ b/src/sodoff.csproj @@ -12,6 +12,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + -- 2.47.2 From c53b6b9348416099c45189019154e1a34b8adb99 Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Sun, 2 Mar 2025 18:20:35 -0800 Subject: [PATCH 3/5] implement ``MessagingService`` add additional messaging schemas --- src/Program.cs | 1 + src/Schema/ArrayOfCombinedListMessage.cs | 12 + .../ArrayOfKeyValuePairOfStringString.cs | 11 + src/Schema/CombinedListMessage.cs | 17 ++ src/Schema/KeyValuePairOfStringString.cs | 13 + src/Schema/Message.cs | 39 +++ src/Services/MessagingService.cs | 237 ++++++++++++++++++ 7 files changed, 330 insertions(+) create mode 100644 src/Schema/ArrayOfCombinedListMessage.cs create mode 100644 src/Schema/ArrayOfKeyValuePairOfStringString.cs create mode 100644 src/Schema/CombinedListMessage.cs create mode 100644 src/Schema/KeyValuePairOfStringString.cs create mode 100644 src/Schema/Message.cs create mode 100644 src/Services/MessagingService.cs diff --git a/src/Program.cs b/src/Program.cs index 1c1cbe9..1bc1dcd 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -41,6 +41,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); bool assetServer = builder.Configuration.GetSection("AssetServer").GetValue("Enabled"); string assetIP = builder.Configuration.GetSection("AssetServer").GetValue("ListenIP"); diff --git a/src/Schema/ArrayOfCombinedListMessage.cs b/src/Schema/ArrayOfCombinedListMessage.cs new file mode 100644 index 0000000..41b52f0 --- /dev/null +++ b/src/Schema/ArrayOfCombinedListMessage.cs @@ -0,0 +1,12 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema +{ + [XmlRoot(ElementName = "ArrayOfCombinedListMessage")] + [Serializable] + public class ArrayOfCombinedListMessage + { + [XmlElement("CombinedListMessage")] + public CombinedListMessage[] CombinedListMessage; + } +} \ No newline at end of file diff --git a/src/Schema/ArrayOfKeyValuePairOfStringString.cs b/src/Schema/ArrayOfKeyValuePairOfStringString.cs new file mode 100644 index 0000000..774fac2 --- /dev/null +++ b/src/Schema/ArrayOfKeyValuePairOfStringString.cs @@ -0,0 +1,11 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema +{ + [XmlRoot(ElementName = "ArrayOfKeyValuePairOfStringString")] + public class ArrayOfKeyValuePairOfStringString + { + [XmlElement(ElementName = "KeyValuePairOfStringString")] + public KeyValuePairOfStringString[]? KeyValuePairOfStringString { get; set; } + } +} \ No newline at end of file diff --git a/src/Schema/CombinedListMessage.cs b/src/Schema/CombinedListMessage.cs new file mode 100644 index 0000000..073702a --- /dev/null +++ b/src/Schema/CombinedListMessage.cs @@ -0,0 +1,17 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema +{ + [Serializable] + public class CombinedListMessage + { + [XmlElement(ElementName = "MessageType")] + public int MessageType; + + [XmlElement(ElementName = "MessageDate")] + public DateTime MessageDate; + + [XmlElement(ElementName = "Body", IsNullable = true)] + public string MessageBody; + } +} \ No newline at end of file diff --git a/src/Schema/KeyValuePairOfStringString.cs b/src/Schema/KeyValuePairOfStringString.cs new file mode 100644 index 0000000..7895231 --- /dev/null +++ b/src/Schema/KeyValuePairOfStringString.cs @@ -0,0 +1,13 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema +{ + [Serializable] + public class KeyValuePairOfStringString + { + [XmlElement(ElementName = "Key")] + public string? Key { get; set; } + [XmlElement(ElementName = "Value")] + public string? Value { get; set; } + } +} diff --git a/src/Schema/Message.cs b/src/Schema/Message.cs new file mode 100644 index 0000000..d423e2f --- /dev/null +++ b/src/Schema/Message.cs @@ -0,0 +1,39 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema +{ + [XmlRoot(ElementName = "Message")] + [Serializable] + public class Message + { + [XmlElement(ElementName = "MessageID")] + public int? MessageID; + + [XmlElement(ElementName = "Creator")] + public string Creator; + + [XmlElement(ElementName = "MessageLevel")] + public MessageLevel MessageLevel; + + [XmlElement(ElementName = "MessageType")] + public MessageType MessageType; + + [XmlElement(ElementName = "Content", IsNullable = true)] + public string? Content; + + [XmlElement(ElementName = "ReplyToMessageID", IsNullable = true)] + public int? ReplyToMessageID; + + [XmlElement(ElementName = "CreateTime")] + public DateTime CreateTime; + + [XmlElement(ElementName = "UpdateDate", IsNullable = true)] + public DateTime? UpdateDate; + + [XmlElement(ElementName = "ConversationID")] + public int ConversationID; + + [XmlElement(ElementName = "DisplayAttribute", IsNullable = true)] + public string? DisplayAttribute; + } +} \ No newline at end of file diff --git a/src/Services/MessagingService.cs b/src/Services/MessagingService.cs new file mode 100644 index 0000000..5c9c3ce --- /dev/null +++ b/src/Services/MessagingService.cs @@ -0,0 +1,237 @@ +using System; +using sodoff.Model; +using sodoff.Schema; +using sodoff.Util; +using ZstdSharp.Unsafe; + +namespace sodoff.Services; + +public class MessagingService +{ + private readonly DBContext ctx; + public MessagingService(DBContext 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, int parentMessageId = 0) + { + // get execution UTC timestamp + DateTime now = DateTime.UtcNow; + + // for generating ConversationId and QueueId + Random rnd = new Random(); + + // construct message + Model.Message message = new Model.Message + { + Viking = viking, + VikingId = viking.Id, + ToViking = toViking, + ToVikingId = toViking.Id, + QueueID = rnd.Next(1000, 9999), + ConversationID = rnd.Next(1000, 9999), + MessageType = messageType, + MessageTypeID = messageTypeID, + MessageLevel = messageLevel, + Data = data, + MemberMessage = memberMessage, + NonMemberMessage = nonMemberMessage, + CreatedAt = now, + LastUpdatedAt = now, + IsDeleted = IsDeleted, + IsNew = IsNew + }; + + if (isReply) + { + // get message this is in reply to + Model.Message? messageToReplyTo = ctx.Messages.FirstOrDefault(e => e.Id == parentMessageId); + + if (messageToReplyTo != null) + { + message.ParentMessage = messageToReplyTo; + message.ParentMessageId = messageToReplyTo.Id; + } else throw new InvalidOperationException("Tried To Reply To A Message That Doesn't Exist"); + } + + // add message to database + ctx.Messages.Add(message); + ctx.SaveChanges(); + + // return constructed message + return message; + } + + public void RemoveMessage(int id) + { + // find message + Model.Message? message = ctx.Messages.FirstOrDefault(e => e.Id == id); + + if (message != null) + { + // remove it + ctx.Messages.Remove(message); + ctx.SaveChanges(); + } else throw new InvalidOperationException("Tried To Delete A Message That Doesn't Exist"); + } + + public Model.Message? UpdateMessage(int id, bool isNew, bool IsDeleted) + { + // get execution UTC timestamp + DateTime now = DateTime.UtcNow; + + // find message + Model.Message? message = ctx.Messages.FirstOrDefault(e => e.Id == id); + + if (message != null) + { + // set params (TODO - figure out what else the clients update in messages) + message.IsNew = isNew; + message.IsDeleted = IsDeleted; + message.LastUpdatedAt = now; + + return message; + } else return null; + } + + public ArrayOfCombinedListMessage ConstructCombinedMessageArray(Viking viking) + { + // get all messages in viking board + List messages = ctx.Messages.Where(e => e.ToVikingId == viking.Id) + .ToList(); + + List combinedListMessages = new List(); + ArrayOfCombinedListMessage response = new ArrayOfCombinedListMessage(); + + foreach(var message in messages) + { + if (message.IsDeleted) + { + ctx.Messages.Remove(message); + continue; + } + + Viking? msgAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == message.VikingId) ?? new Viking(); + + // construct a CombinedListMessage based on Model.Message + CombinedListMessage clm = new CombinedListMessage + { + MessageType = (int?)message.MessageType ?? 0, + MessageDate = message.CreatedAt + }; + + // if type id is messaging, use Schema.Message, otherwise treat it as Schema.MessageInfo + if (message.MessageTypeID == MessageTypeID.Messaging) + { + clm.MessageBody = XmlUtil.SerializeXml(new Schema.Message + { + MessageID = message.Id, + ConversationID = message.ConversationID ?? 0, + ReplyToMessageID = message.ParentMessageId, + Creator = msgAuthor.Uid.ToString() ?? "Ghost", + CreateTime = message.CreatedAt, + UpdateDate = message.LastUpdatedAt, + MessageType = message.MessageType.Value, + MessageLevel = message.MessageLevel, + Content = message.Data ?? "No Data Found In This Message. This Might Be An Error.", + DisplayAttribute = "C=White" // still having it always white :) + }); + } else if (message.Data.StartsWith("(message.Data); + string data = ""; + List pairList = new List(); + + for(int i = 0; i < arrayOfKVP.KeyValuePairOfStringString.Length; i++) + { + pairList.Add(arrayOfKVP.KeyValuePairOfStringString[i]); + } + + foreach(KeyValuePairOfStringString pair in pairList) + { + data = data + $"[[{pair.Key}]]=[[{pair.Value}]]"; + } + + clm.MessageBody = XmlUtil.SerializeXml(new MessageInfo + { + UserMessageQueueID = message.QueueID, + MessageID = message.Id, + MessageTypeID = (int?)message.MessageTypeID, + FromUserID = msgAuthor.Uid.ToString() ?? "NotFound", + MemberMessage = message.MemberMessage ?? "NoData", + NonMemberMessage = message.NonMemberMessage ?? "NoData", + Data = data + }); + + } else + { + clm.MessageBody = XmlUtil.SerializeXml(new MessageInfo + { + UserMessageQueueID = message.QueueID, + MessageID = message.Id, + MessageTypeID = (int?)message.MessageTypeID, + FromUserID = msgAuthor.Uid.ToString() ?? "NotFound", + MemberMessage = message.MemberMessage ?? "NoData", + NonMemberMessage = message.NonMemberMessage ?? "NoData", + Data = message.Data + }); + } + + // add clm to list + combinedListMessages.Add(clm); + } + + // save any changes made to db + ctx.SaveChanges(); + + // sort messages by newest first + combinedListMessages = combinedListMessages.OrderBy(e => e.MessageDate).ToList(); + + // add list as array to response + response.CombinedListMessage = combinedListMessages.ToArray(); + + // return response + return response; + } + + public ArrayOfMessageInfo ConstructUserMessageInfoArray(Viking viking, bool showOldMessages, bool showDeletedMessages) + { + // get execution UTC timestamp + DateTime now = DateTime.UtcNow; + + // get all recent messages + List messages = ctx.Messages.Where(e => e.ToVikingId == viking.Id) + .OrderBy(e => e.CreatedAt) + .OrderBy(e => e.QueueID) + .ToList(); + + List messageInfos = new List(0); + ArrayOfMessageInfo response = new ArrayOfMessageInfo(); + + foreach(var message in messages) + { + Viking? msgAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == message.VikingId) ?? new Viking(); + + if(!showOldMessages && message.IsNew && DateTime.Compare(message.CreatedAt, now.AddMinutes(30)) > 0 || message.IsDeleted) continue; // sometimes clients won't set IsNew flag when updating messages, so do not add messages more than 30 minutes old to response + if(!message.IsNew && !showOldMessages) continue; + messageInfos.Add(new MessageInfo + { + MessageID = message.Id, + UserMessageQueueID = message.QueueID, + FromUserID = msgAuthor.Uid.ToString() ?? "NotFound", + MessageTypeID = (int?)message.MessageTypeID, + Data = message.Data ?? "NoData", + MemberMessage = message.MemberMessage ?? "NoMessage", + NonMemberMessage = message.NonMemberMessage ?? "NoMessage" + }); + } + + // add list as array to response + response.MessageInfo = messageInfos.ToArray(); + + // return response + return response; + } +} -- 2.47.2 From 157f8fc45549cbf162b67269685dac031a2250ba Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Sun, 2 Mar 2025 18:52:22 -0800 Subject: [PATCH 4/5] implement endpoints in ``MessagingController`` --- src/Controllers/Common/MessagingController.cs | 71 +++++++++++++++---- src/Services/MessagingService.cs | 8 +-- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/Controllers/Common/MessagingController.cs b/src/Controllers/Common/MessagingController.cs index b4e71de..1385c70 100644 --- a/src/Controllers/Common/MessagingController.cs +++ b/src/Controllers/Common/MessagingController.cs @@ -1,39 +1,86 @@ using Microsoft.AspNetCore.Mvc; +using sodoff.Attributes; +using sodoff.Model; using sodoff.Schema; +using sodoff.Services; +using sodoff.Util; namespace sodoff.Controllers.Common; public class MessagingController : Controller { + private readonly MessagingService messagingService; + private readonly DBContext ctx; + public MessagingController(MessagingService messagingService, DBContext ctx) + { + this.messagingService = messagingService; + this.ctx = ctx; + } + [HttpPost] [Produces("application/xml")] [Route("MessagingWebService.asmx/GetUserMessageQueue")] - public ArrayOfMessageInfo? GetUserMessageQueue() { - // TODO: this is a placeholder - return null; + [VikingSession] + public ArrayOfMessageInfo? GetUserMessageQueue(Viking viking, [FromForm] bool showOldMessages, [FromForm] bool showDeletedMessages) { + return messagingService.ConstructUserMessageInfoArray(viking, showOldMessages, showDeletedMessages); } [HttpPost] [Produces("application/xml")] [Route("MessagingWebService.asmx/SendMessage")] - public IActionResult SendMessage() { - // TODO: this is a placeholder - return Ok(false); + [VikingSession] + public IActionResult SendMessage(Viking viking, [FromForm] Guid toUser, [FromForm] int messageID, [FromForm] string data) { + // find viking to send to + Viking? toViking = ctx.Vikings.FirstOrDefault(e => e.Uid == toUser); + if (toViking == null) return Ok(false); + + // clients (at least older ones) don't send what typeID the message is, its encoded in data + ArrayOfKeyValuePairOfStringString arrayOfKeyValuePairOfStringString = XmlUtil.DeserializeXml(data); + MessageTypeID typeID = MessageTypeID.Unknown; + string typeText = ""; + switch(arrayOfKeyValuePairOfStringString.KeyValuePairOfStringString[0]?.Value) + { + case "Drawing": + typeID = MessageTypeID.GreetingCard; + typeText = "Card"; + break; + case "Photo": + typeID = MessageTypeID.Photo; + typeText = "PhotoBomb"; + break; + } + + var msg = messagingService.AddMessageToViking(viking, toViking, MessageType.Data, typeID, MessageLevel.WhiteList, data, "[[Line1]]=[[{{BuddyUserName}}]] has sent you a " + typeText + "!", "[[Line1]]=[[{{BuddyUserName}}]] has sent you a " + typeText + "!"); + if (msg != null) return Ok(true); + else return Ok(false); } [HttpPost] [Produces("application/xml")] [Route("MessagingWebService.asmx/SaveMessage")] - public IActionResult SaveMessage() { - // TODO: this is a placeholder - return Ok(false); + public IActionResult SaveMessage([FromForm] int userMessageQueueId, [FromForm] bool isNew, [FromForm] bool IsDeleted) { + var updatedMessage = messagingService.UpdateMessageByQueueID(userMessageQueueId, isNew, IsDeleted); + if (updatedMessage != null) return Ok(true); + else return Ok(false); } [HttpPost] [Produces("application/xml")] [Route("MessageWebService.asmx/GetCombinedListMessage")] - public IActionResult GetCombinedListMessage() + public ArrayOfCombinedListMessage? GetCombinedListMessage([FromForm] Guid userId) { - // TODO - placeholder - return Ok(new ArrayOfMessageInfo()); + // find viking + Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId); + + if (viking != null) return messagingService.ConstructCombinedMessageArray(viking); + else return new ArrayOfCombinedListMessage(); + } + + [HttpPost] + [Produces("application/xml")] + [Route("MessageWebService.asmx/RemoveMessageFromBoard")] + public IActionResult RemoveMessageFromBoard([FromForm] int messageID) + { + messagingService.RemoveMessage(messageID); + return Ok(true); } } diff --git a/src/Services/MessagingService.cs b/src/Services/MessagingService.cs index 5c9c3ce..aa21370 100644 --- a/src/Services/MessagingService.cs +++ b/src/Services/MessagingService.cs @@ -76,13 +76,13 @@ public class MessagingService } else throw new InvalidOperationException("Tried To Delete A Message That Doesn't Exist"); } - public Model.Message? UpdateMessage(int id, bool isNew, bool IsDeleted) + public Model.Message? UpdateMessageByQueueID(int queueId, bool isNew, bool IsDeleted) { // get execution UTC timestamp DateTime now = DateTime.UtcNow; // find message - Model.Message? message = ctx.Messages.FirstOrDefault(e => e.Id == id); + Model.Message? message = ctx.Messages.FirstOrDefault(e => e.QueueID == queueId); if (message != null) { @@ -207,14 +207,14 @@ public class MessagingService .OrderBy(e => e.QueueID) .ToList(); - List messageInfos = new List(0); + List messageInfos = new List(); ArrayOfMessageInfo response = new ArrayOfMessageInfo(); foreach(var message in messages) { Viking? msgAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == message.VikingId) ?? new Viking(); - if(!showOldMessages && message.IsNew && DateTime.Compare(message.CreatedAt, now.AddMinutes(30)) > 0 || message.IsDeleted) continue; // sometimes clients won't set IsNew flag when updating messages, so do not add messages more than 30 minutes old to response + if(!showOldMessages && message.IsNew && DateTime.Compare(message.CreatedAt.AddMinutes(30), now) > 0 || message.IsDeleted) continue; // sometimes clients won't set IsNew flag when updating messages, so do not add messages more than 30 minutes old to response if(!message.IsNew && !showOldMessages) continue; messageInfos.Add(new MessageInfo { -- 2.47.2 From 4922223bb29bdfe06e3d7a8825b71c1147452c37 Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Sun, 2 Mar 2025 19:56:11 -0800 Subject: [PATCH 5/5] fix issues with replies --- src/Services/MessagingService.cs | 36 ++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Services/MessagingService.cs b/src/Services/MessagingService.cs index aa21370..9c60a33 100644 --- a/src/Services/MessagingService.cs +++ b/src/Services/MessagingService.cs @@ -1,4 +1,5 @@ using System; +using Microsoft.EntityFrameworkCore; using sodoff.Model; using sodoff.Schema; using sodoff.Util; @@ -52,6 +53,7 @@ public class MessagingService { message.ParentMessage = messageToReplyTo; message.ParentMessageId = messageToReplyTo.Id; + message.ConversationID = messageToReplyTo.ConversationID; } else throw new InvalidOperationException("Tried To Reply To A Message That Doesn't Exist"); } @@ -98,8 +100,7 @@ public class MessagingService public ArrayOfCombinedListMessage ConstructCombinedMessageArray(Viking viking) { // get all messages in viking board - List messages = ctx.Messages.Where(e => e.ToVikingId == viking.Id) - .ToList(); + List messages = ctx.Messages.Where(e => e.ToVikingId == viking.Id).ToList(); List combinedListMessages = new List(); ArrayOfCombinedListMessage response = new ArrayOfCombinedListMessage(); @@ -181,13 +182,40 @@ public class MessagingService // add clm to list combinedListMessages.Add(clm); + + // ensure all replies are included in response + foreach(var reply in message.Replies) + { + Viking? replyAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == reply.VikingId) ?? new Viking(); + + CombinedListMessage clmReply = new CombinedListMessage + { + MessageType = (int)reply.MessageType, + MessageBody = XmlUtil.SerializeXml(new Schema.Message + { + MessageID = reply.Id, + ConversationID = reply.ConversationID ?? 0, + ReplyToMessageID = reply.ParentMessageId, + Creator = replyAuthor.Uid.ToString() ?? "Ghost", + CreateTime = reply.CreatedAt, + UpdateDate = reply.LastUpdatedAt, + MessageType = reply.MessageType.Value, + MessageLevel = reply.MessageLevel, + Content = reply.Data ?? "No Data Found In This Message. This Might Be An Error.", + DisplayAttribute = "C=White" // still having it always white :) + }), + MessageDate = reply.CreatedAt + }; + + combinedListMessages.Add(clmReply); + } } // save any changes made to db ctx.SaveChanges(); - // sort messages by newest first - combinedListMessages = combinedListMessages.OrderBy(e => e.MessageDate).ToList(); + // reverse list + combinedListMessages.Reverse(); // add list as array to response response.CombinedListMessage = combinedListMessages.ToArray(); -- 2.47.2