diff --git a/Server/DB/Migrations/20230817230423_CharacterDataDraft.Designer.cs b/Server/DB/Migrations/20230817230423_CharacterDataDraft.Designer.cs
new file mode 100644
index 0000000..22b50ac
--- /dev/null
+++ b/Server/DB/Migrations/20230817230423_CharacterDataDraft.Designer.cs
@@ -0,0 +1,115 @@
+//
+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("20230817230423_CharacterDataDraft")]
+ partial class CharacterDataDraft
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.10")
+ .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.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.Account", b =>
+ {
+ b.Navigation("Characters");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Server/DB/Migrations/20230817230423_CharacterDataDraft.cs b/Server/DB/Migrations/20230817230423_CharacterDataDraft.cs
new file mode 100644
index 0000000..41ed2f8
--- /dev/null
+++ b/Server/DB/Migrations/20230817230423_CharacterDataDraft.cs
@@ -0,0 +1,126 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Server.DB.Migrations
+{
+ ///
+ public partial class CharacterDataDraft : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "Username",
+ table: "Accounts",
+ type: "varchar(20)",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "varchar(20)");
+
+ migrationBuilder.AlterColumn(
+ name: "Salt",
+ table: "Accounts",
+ type: "bytea",
+ nullable: true,
+ oldClrType: typeof(byte[]),
+ oldType: "bytea");
+
+ migrationBuilder.AlterColumn(
+ name: "Password",
+ table: "Accounts",
+ type: "bytea",
+ nullable: true,
+ oldClrType: typeof(byte[]),
+ oldType: "bytea");
+
+ migrationBuilder.AlterColumn(
+ name: "Email",
+ table: "Accounts",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.CreateTable(
+ name: "Characters",
+ columns: table => new
+ {
+ Id = table.Column(type: "uuid", nullable: false),
+ ServerId = table.Column(type: "smallint", nullable: false),
+ AccountId = table.Column(type: "uuid", nullable: false),
+ MapId = table.Column(type: "integer", nullable: false),
+ Name = table.Column(type: "varchar(20)", nullable: true),
+ LastXCoordinate = table.Column(type: "smallint", nullable: false),
+ LastYCoordinate = table.Column(type: "smallint", nullable: false),
+ PvPLevel = table.Column(type: "smallint", nullable: false),
+ Gender = table.Column(type: "smallint", nullable: false),
+ Experience = table.Column(type: "bigint", nullable: false),
+ Level = table.Column(type: "smallint", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Characters", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Characters_Accounts_AccountId",
+ column: x => x.AccountId,
+ principalTable: "Accounts",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Characters_AccountId",
+ table: "Characters",
+ column: "AccountId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Characters");
+
+ migrationBuilder.AlterColumn(
+ name: "Username",
+ table: "Accounts",
+ type: "varchar(20)",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "varchar(20)",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Salt",
+ table: "Accounts",
+ type: "bytea",
+ nullable: false,
+ defaultValue: new byte[0],
+ oldClrType: typeof(byte[]),
+ oldType: "bytea",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Password",
+ table: "Accounts",
+ type: "bytea",
+ nullable: false,
+ defaultValue: new byte[0],
+ oldClrType: typeof(byte[]),
+ oldType: "bytea",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Email",
+ table: "Accounts",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+ }
+ }
+}
diff --git a/Server/DB/Migrations/WonderkingContextModelSnapshot.cs b/Server/DB/Migrations/WonderkingContextModelSnapshot.cs
index 5b2e1f5..51f1e73 100644
--- a/Server/DB/Migrations/WonderkingContextModelSnapshot.cs
+++ b/Server/DB/Migrations/WonderkingContextModelSnapshot.cs
@@ -29,28 +29,83 @@ namespace Server.DB.Migrations
.HasColumnType("uuid");
b.Property("Email")
- .IsRequired()
.HasColumnType("text");
b.Property("Password")
- .IsRequired()
.HasColumnType("bytea");
b.Property("PermissionLevel")
.HasColumnType("smallint");
b.Property("Salt")
- .IsRequired()
.HasColumnType("bytea");
b.Property("Username")
- .IsRequired()
.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.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.Account", b =>
+ {
+ b.Navigation("Characters");
+ });
#pragma warning restore 612, 618
}
}
diff --git a/Server/DB/WonderkingContext.cs b/Server/DB/WonderkingContext.cs
index 4ad9982..dfd3c5e 100644
--- a/Server/DB/WonderkingContext.cs
+++ b/Server/DB/WonderkingContext.cs
@@ -36,7 +36,6 @@ public class WonderkingContext : DbContext
}).Entity(builder =>
{
builder.HasKey(c => c.Id);
- builder.HasOne().WithOne().HasForeignKey("AccountId").IsRequired();
builder.Property(c => c.Name).HasColumnType("varchar(20)");
});
}