From cb087f53e940e6c041a9e55cb80961506d7115d4 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Wed, 8 Nov 2023 15:39:25 +0100 Subject: [PATCH] chore: add migration for inventory data --- ...143729_AddInventoryToCharacter.Designer.cs | 183 ++++++++++++++++++ .../20231108143729_AddInventoryToCharacter.cs | 55 ++++++ .../WonderkingContextModelSnapshot.cs | 70 ++++++- Server/Server.csproj | 4 + 4 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 Server/DB/Migrations/20231108143729_AddInventoryToCharacter.Designer.cs create mode 100644 Server/DB/Migrations/20231108143729_AddInventoryToCharacter.cs diff --git a/Server/DB/Migrations/20231108143729_AddInventoryToCharacter.Designer.cs b/Server/DB/Migrations/20231108143729_AddInventoryToCharacter.Designer.cs new file mode 100644 index 0000000..86952dc --- /dev/null +++ b/Server/DB/Migrations/20231108143729_AddInventoryToCharacter.Designer.cs @@ -0,0 +1,183 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Server.DB; + +#nullable disable + +namespace Server.DB.Migrations +{ + [DbContext(typeof(WonderkingContext))] + [Migration("20231108143729_AddInventoryToCharacter")] + partial class AddInventoryToCharacter + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.13") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Server.DB.Documents.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("Password") + .HasColumnType("bytea"); + + b.Property("PermissionLevel") + .HasColumnType("smallint"); + + b.Property("Salt") + .HasColumnType("bytea"); + + b.Property("Username") + .HasColumnType("varchar(20)"); + + b.HasKey("Id"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Server.DB.Documents.Character", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("Experience") + .HasColumnType("bigint"); + + b.Property("Gender") + .HasColumnType("smallint"); + + b.Property("LastXCoordinate") + .HasColumnType("smallint"); + + b.Property("LastYCoordinate") + .HasColumnType("smallint"); + + b.Property("Level") + .HasColumnType("smallint"); + + b.Property("MapId") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("varchar(20)"); + + b.Property("PvPLevel") + .HasColumnType("smallint"); + + b.Property("ServerId") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.ToTable("Characters"); + }); + + modelBuilder.Entity("Server.DB.Documents.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddOption") + .HasColumnType("smallint"); + + b.Property("AddOption2") + .HasColumnType("smallint"); + + b.Property("AddOption3") + .HasColumnType("smallint"); + + b.Property("CharacterId") + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ItemId") + .HasColumnType("smallint"); + + b.Property("ItemType") + .HasColumnType("smallint"); + + b.Property("Level") + .HasColumnType("smallint"); + + b.Property("Option") + .HasColumnType("smallint"); + + b.Property("Option2") + .HasColumnType("smallint"); + + b.Property("Option3") + .HasColumnType("smallint"); + + b.Property("Rarity") + .HasColumnType("smallint"); + + b.Property("Slot") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.ToTable("InventoryItem"); + }); + + modelBuilder.Entity("Server.DB.Documents.Character", b => + { + b.HasOne("Server.DB.Documents.Account", "Account") + .WithMany("Characters") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("Server.DB.Documents.InventoryItem", b => + { + b.HasOne("Server.DB.Documents.Character", "Character") + .WithMany("InventoryItems") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + }); + + modelBuilder.Entity("Server.DB.Documents.Account", b => + { + b.Navigation("Characters"); + }); + + modelBuilder.Entity("Server.DB.Documents.Character", b => + { + b.Navigation("InventoryItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/DB/Migrations/20231108143729_AddInventoryToCharacter.cs b/Server/DB/Migrations/20231108143729_AddInventoryToCharacter.cs new file mode 100644 index 0000000..4e365ba --- /dev/null +++ b/Server/DB/Migrations/20231108143729_AddInventoryToCharacter.cs @@ -0,0 +1,55 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Server.DB.Migrations; + +/// +public partial class AddInventoryToCharacter : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "InventoryItem", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CharacterId = table.Column(type: "uuid", nullable: false), + ItemId = table.Column(type: "smallint", nullable: false), + Count = table.Column(type: "integer", nullable: false), + Slot = table.Column(type: "smallint", nullable: false), + ItemType = table.Column(type: "smallint", nullable: false), + Level = table.Column(type: "smallint", nullable: false), + Rarity = table.Column(type: "smallint", nullable: false), + AddOption = table.Column(type: "smallint", nullable: false), + AddOption2 = table.Column(type: "smallint", nullable: false), + AddOption3 = table.Column(type: "smallint", nullable: false), + Option = table.Column(type: "smallint", nullable: false), + Option2 = table.Column(type: "smallint", nullable: false), + Option3 = table.Column(type: "smallint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InventoryItem", x => x.Id); + table.ForeignKey( + name: "FK_InventoryItem_Characters_CharacterId", + column: x => x.CharacterId, + principalTable: "Characters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_InventoryItem_CharacterId", + table: "InventoryItem", + column: "CharacterId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "InventoryItem"); + } +} diff --git a/Server/DB/Migrations/WonderkingContextModelSnapshot.cs b/Server/DB/Migrations/WonderkingContextModelSnapshot.cs index 51f1e73..ab1f034 100644 --- a/Server/DB/Migrations/WonderkingContextModelSnapshot.cs +++ b/Server/DB/Migrations/WonderkingContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace Server.DB.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.10") + .HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -91,6 +91,58 @@ namespace Server.DB.Migrations b.ToTable("Characters"); }); + modelBuilder.Entity("Server.DB.Documents.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddOption") + .HasColumnType("smallint"); + + b.Property("AddOption2") + .HasColumnType("smallint"); + + b.Property("AddOption3") + .HasColumnType("smallint"); + + b.Property("CharacterId") + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ItemId") + .HasColumnType("smallint"); + + b.Property("ItemType") + .HasColumnType("smallint"); + + b.Property("Level") + .HasColumnType("smallint"); + + b.Property("Option") + .HasColumnType("smallint"); + + b.Property("Option2") + .HasColumnType("smallint"); + + b.Property("Option3") + .HasColumnType("smallint"); + + b.Property("Rarity") + .HasColumnType("smallint"); + + b.Property("Slot") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.ToTable("InventoryItem"); + }); + modelBuilder.Entity("Server.DB.Documents.Character", b => { b.HasOne("Server.DB.Documents.Account", "Account") @@ -102,10 +154,26 @@ namespace Server.DB.Migrations b.Navigation("Account"); }); + modelBuilder.Entity("Server.DB.Documents.InventoryItem", b => + { + b.HasOne("Server.DB.Documents.Character", "Character") + .WithMany("InventoryItems") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + }); + modelBuilder.Entity("Server.DB.Documents.Account", b => { b.Navigation("Characters"); }); + + modelBuilder.Entity("Server.DB.Documents.Character", b => + { + b.Navigation("InventoryItems"); + }); #pragma warning restore 612, 618 } } diff --git a/Server/Server.csproj b/Server/Server.csproj index 0aec4a7..05c9822 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -66,6 +66,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +