continuity/Continuity.AuthServer/DB/Migrations/20230817230423_CharacterDataDraft.cs

121 lines
4.1 KiB
C#
Raw Permalink Normal View History

2024-02-07 15:40:36 +00:00
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
2023-11-20 18:58:30 +00:00
2023-08-17 23:09:27 +00:00
#nullable disable
2023-10-12 07:15:34 +00:00
namespace Server.DB.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
/// <inheritdoc />
public partial class CharacterDataDraft : Migration {
2023-08-17 23:09:27 +00:00
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) {
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<string>(
name: "Username",
table: "Accounts",
type: "varchar(20)",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(20)");
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<byte[]>(
name: "Salt",
table: "Accounts",
type: "bytea",
nullable: true,
oldClrType: typeof(byte[]),
oldType: "bytea");
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<byte[]>(
name: "Password",
table: "Accounts",
type: "bytea",
nullable: true,
oldClrType: typeof(byte[]),
oldType: "bytea");
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Accounts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.CreateTable(
name: "Characters",
columns: table => new {
2023-10-12 07:15:34 +00:00
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 => {
2023-10-12 07:15:34 +00:00
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);
});
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.CreateIndex(
name: "IX_Characters_AccountId",
table: "Characters",
column: "AccountId");
}
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) {
2023-10-12 07:15:34 +00:00
migrationBuilder.DropTable(
name: "Characters");
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<string>(
name: "Username",
table: "Accounts",
type: "varchar(20)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "varchar(20)",
oldNullable: true);
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<byte[]>(
name: "Salt",
table: "Accounts",
type: "bytea",
nullable: false,
defaultValue: Array.Empty<byte>(),
oldClrType: typeof(byte[]),
oldType: "bytea",
oldNullable: true);
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<byte[]>(
name: "Password",
table: "Accounts",
type: "bytea",
nullable: false,
defaultValue: Array.Empty<byte>(),
oldClrType: typeof(byte[]),
oldType: "bytea",
oldNullable: true);
2023-08-17 23:09:27 +00:00
2023-10-12 07:15:34 +00:00
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Accounts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
2023-08-17 23:09:27 +00:00
}
}