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-11-15 19:00:08 +00:00
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
namespace Server.DB.Migrations;
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public partial class SwitchToDataAnnotations : Migration
|
|
|
|
{
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
{
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Guild_GuildId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Guild_GuildId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropIndex(
|
|
|
|
name: "IX_Characters_Name",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropColumn(
|
|
|
|
name: "ServerId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "GuildId",
|
|
|
|
table: "GuildMember",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "CharacterId",
|
|
|
|
table: "GuildMember",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Name",
|
|
|
|
table: "Characters",
|
|
|
|
type: "text",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "varchar(20)",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "GuildId",
|
|
|
|
table: "Characters",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "AccountId",
|
|
|
|
table: "Characters",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid");
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
name: "IX_Accounts_Id",
|
|
|
|
table: "Accounts",
|
|
|
|
column: "Id",
|
|
|
|
unique: true);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "AccountId",
|
|
|
|
principalTable: "Accounts",
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Guild_GuildId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guild",
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "CharacterId",
|
|
|
|
principalTable: "Characters",
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Guild_GuildId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guild",
|
|
|
|
principalColumn: "Id");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
{
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Guild_GuildId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Guild_GuildId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropIndex(
|
|
|
|
name: "IX_Accounts_Id",
|
|
|
|
table: "Accounts");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "GuildId",
|
|
|
|
table: "GuildMember",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: false,
|
|
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "CharacterId",
|
|
|
|
table: "GuildMember",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: false,
|
|
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Name",
|
|
|
|
table: "Characters",
|
|
|
|
type: "varchar(20)",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "text",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "GuildId",
|
|
|
|
table: "Characters",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: false,
|
|
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<Guid>(
|
|
|
|
name: "AccountId",
|
|
|
|
table: "Characters",
|
|
|
|
type: "uuid",
|
|
|
|
nullable: false,
|
|
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
|
|
|
oldClrType: typeof(Guid),
|
|
|
|
oldType: "uuid",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AddColumn<byte>(
|
|
|
|
name: "ServerId",
|
|
|
|
table: "Characters",
|
|
|
|
type: "smallint",
|
|
|
|
nullable: false,
|
|
|
|
defaultValue: (byte)0);
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
name: "IX_Characters_Name",
|
|
|
|
table: "Characters",
|
|
|
|
column: "Name",
|
|
|
|
unique: true);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "AccountId",
|
|
|
|
principalTable: "Accounts",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Guild_GuildId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guild",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "CharacterId",
|
|
|
|
principalTable: "Characters",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Guild_GuildId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guild",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
}
|
|
|
|
}
|