continuity/Server/DB/Migrations/20230817230423_CharacterDataDraft.cs
Timothy Schenk e58fa35941
All checks were successful
Test if Server can be built / build-server (push) Successful in 24s
feat: first draft for character data
2023-08-18 01:09:27 +02:00

126 lines
4.5 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Server.DB.Migrations
{
/// <inheritdoc />
public partial class CharacterDataDraft : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Username",
table: "Accounts",
type: "varchar(20)",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(20)");
migrationBuilder.AlterColumn<byte[]>(
name: "Salt",
table: "Accounts",
type: "bytea",
nullable: true,
oldClrType: typeof(byte[]),
oldType: "bytea");
migrationBuilder.AlterColumn<byte[]>(
name: "Password",
table: "Accounts",
type: "bytea",
nullable: true,
oldClrType: typeof(byte[]),
oldType: "bytea");
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Accounts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.CreateTable(
name: "Characters",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ServerId = table.Column<byte>(type: "smallint", nullable: false),
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
MapId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "varchar(20)", nullable: true),
LastXCoordinate = table.Column<short>(type: "smallint", nullable: false),
LastYCoordinate = table.Column<short>(type: "smallint", nullable: false),
PvPLevel = table.Column<byte>(type: "smallint", nullable: false),
Gender = table.Column<byte>(type: "smallint", nullable: false),
Experience = table.Column<long>(type: "bigint", nullable: false),
Level = table.Column<byte>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Characters");
migrationBuilder.AlterColumn<string>(
name: "Username",
table: "Accounts",
type: "varchar(20)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "varchar(20)",
oldNullable: true);
migrationBuilder.AlterColumn<byte[]>(
name: "Salt",
table: "Accounts",
type: "bytea",
nullable: false,
defaultValue: new byte[0],
oldClrType: typeof(byte[]),
oldType: "bytea",
oldNullable: true);
migrationBuilder.AlterColumn<byte[]>(
name: "Password",
table: "Accounts",
type: "bytea",
nullable: false,
defaultValue: new byte[0],
oldClrType: typeof(byte[]),
oldType: "bytea",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Accounts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
}
}