// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Server.DB.Migrations;
///
public partial class FixEntityRelationships : Migration {
///
protected override void Up(MigrationBuilder migrationBuilder) {
migrationBuilder.DropForeignKey(
name: "FK_Accounts_GuildMember_GuildMemberId",
table: "Accounts");
migrationBuilder.DropForeignKey(
name: "FK_Characters_Guilds_GuildId",
table: "Characters");
migrationBuilder.DropIndex(
name: "IX_GuildMember_CharacterId",
table: "GuildMember");
migrationBuilder.DropIndex(
name: "IX_Characters_GuildId",
table: "Characters");
migrationBuilder.DropIndex(
name: "IX_Accounts_GuildMemberId",
table: "Accounts");
migrationBuilder.DropColumn(
name: "GuildId",
table: "Characters");
migrationBuilder.DropColumn(
name: "GuildMemberId",
table: "Accounts");
migrationBuilder.AlterColumn(
name: "CharacterId",
table: "InventoryItems",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AlterColumn(
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(
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(
name: "AccountId",
table: "Characters",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_GuildMember_CharacterId",
table: "GuildMember",
column: "CharacterId",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder) {
migrationBuilder.DropIndex(
name: "IX_GuildMember_CharacterId",
table: "GuildMember");
migrationBuilder.AlterColumn(
name: "CharacterId",
table: "InventoryItems",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AlterColumn(
name: "GuildId",
table: "GuildMember",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AlterColumn(
name: "CharacterId",
table: "GuildMember",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AlterColumn(
name: "AccountId",
table: "Characters",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn(
name: "GuildId",
table: "Characters",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn(
name: "GuildMemberId",
table: "Accounts",
type: "uuid",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_GuildMember_CharacterId",
table: "GuildMember",
column: "CharacterId");
migrationBuilder.CreateIndex(
name: "IX_Characters_GuildId",
table: "Characters",
column: "GuildId");
migrationBuilder.CreateIndex(
name: "IX_Accounts_GuildMemberId",
table: "Accounts",
column: "GuildMemberId");
migrationBuilder.AddForeignKey(
name: "FK_Accounts_GuildMember_GuildMemberId",
table: "Accounts",
column: "GuildMemberId",
principalTable: "GuildMember",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Characters_Guilds_GuildId",
table: "Characters",
column: "GuildId",
principalTable: "Guilds",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}