continuity/Server/DB/Migrations/20231125112400_FixEntityRelationships.cs
Timothy Schenk 3efe3a5aac
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 27s
Build, Package and Push Images / sbom-scan (push) Successful in 38s
Build, Package and Push Images / container-build (push) Successful in 1m20s
Build, Package and Push Images / sonarqube (push) Successful in 1m27s
Build, Package and Push Images / container-sbom-scan (push) Successful in 34s
fix: relationships bit messy
2023-11-25 12:24:42 +01:00

172 lines
5.1 KiB
C#

// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Server.DB.Migrations;
/// <inheritdoc />
public partial class FixEntityRelationships : Migration
{
/// <inheritdoc />
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<Guid>(
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<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<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.CreateIndex(
name: "IX_GuildMember_CharacterId",
table: "GuildMember",
column: "CharacterId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_GuildMember_CharacterId",
table: "GuildMember");
migrationBuilder.AlterColumn<Guid>(
name: "CharacterId",
table: "InventoryItems",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
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<Guid>(
name: "AccountId",
table: "Characters",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn<Guid>(
name: "GuildId",
table: "Characters",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
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);
}
}