using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TrackQrApi.Migrations
{
    /// <inheritdoc />
    public partial class RefactorAuth : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Events_QRCodeDesigns_QRCodeId",
                table: "Events");

            migrationBuilder.DropForeignKey(
                name: "FK_QRCodeDesigns_Assets_LogoAssetId",
                table: "QRCodeDesigns");

            migrationBuilder.DropForeignKey(
                name: "FK_QRCodeDesigns_Projects_ProjectId",
                table: "QRCodeDesigns");

            migrationBuilder.DropForeignKey(
                name: "FK_QRCodeDesigns_ShortLinks_ShortLinkId",
                table: "QRCodeDesigns");

            migrationBuilder.DropForeignKey(
                name: "FK_QRCodeDesigns_Workspaces_WorkspaceId",
                table: "QRCodeDesigns");

            migrationBuilder.DropPrimaryKey(
                name: "PK_QRCodeDesigns",
                table: "QRCodeDesigns");

            migrationBuilder.RenameTable(
                name: "QRCodeDesigns",
                newName: "QrCodeDesigns");

            migrationBuilder.RenameIndex(
                name: "IX_QRCodeDesigns_WorkspaceId",
                table: "QrCodeDesigns",
                newName: "IX_QrCodeDesigns_WorkspaceId");

            migrationBuilder.RenameIndex(
                name: "IX_QRCodeDesigns_ShortLinkId",
                table: "QrCodeDesigns",
                newName: "IX_QrCodeDesigns_ShortLinkId");

            migrationBuilder.RenameIndex(
                name: "IX_QRCodeDesigns_ProjectId",
                table: "QrCodeDesigns",
                newName: "IX_QrCodeDesigns_ProjectId");

            migrationBuilder.RenameIndex(
                name: "IX_QRCodeDesigns_LogoAssetId",
                table: "QrCodeDesigns",
                newName: "IX_QrCodeDesigns_LogoAssetId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_QrCodeDesigns",
                table: "QrCodeDesigns",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Events_QrCodeDesigns_QRCodeId",
                table: "Events",
                column: "QRCodeId",
                principalTable: "QrCodeDesigns",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QrCodeDesigns_Assets_LogoAssetId",
                table: "QrCodeDesigns",
                column: "LogoAssetId",
                principalTable: "Assets",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QrCodeDesigns_Projects_ProjectId",
                table: "QrCodeDesigns",
                column: "ProjectId",
                principalTable: "Projects",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QrCodeDesigns_ShortLinks_ShortLinkId",
                table: "QrCodeDesigns",
                column: "ShortLinkId",
                principalTable: "ShortLinks",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QrCodeDesigns_Workspaces_WorkspaceId",
                table: "QrCodeDesigns",
                column: "WorkspaceId",
                principalTable: "Workspaces",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Events_QrCodeDesigns_QRCodeId",
                table: "Events");

            migrationBuilder.DropForeignKey(
                name: "FK_QrCodeDesigns_Assets_LogoAssetId",
                table: "QrCodeDesigns");

            migrationBuilder.DropForeignKey(
                name: "FK_QrCodeDesigns_Projects_ProjectId",
                table: "QrCodeDesigns");

            migrationBuilder.DropForeignKey(
                name: "FK_QrCodeDesigns_ShortLinks_ShortLinkId",
                table: "QrCodeDesigns");

            migrationBuilder.DropForeignKey(
                name: "FK_QrCodeDesigns_Workspaces_WorkspaceId",
                table: "QrCodeDesigns");

            migrationBuilder.DropPrimaryKey(
                name: "PK_QrCodeDesigns",
                table: "QrCodeDesigns");

            migrationBuilder.RenameTable(
                name: "QrCodeDesigns",
                newName: "QRCodeDesigns");

            migrationBuilder.RenameIndex(
                name: "IX_QrCodeDesigns_WorkspaceId",
                table: "QRCodeDesigns",
                newName: "IX_QRCodeDesigns_WorkspaceId");

            migrationBuilder.RenameIndex(
                name: "IX_QrCodeDesigns_ShortLinkId",
                table: "QRCodeDesigns",
                newName: "IX_QRCodeDesigns_ShortLinkId");

            migrationBuilder.RenameIndex(
                name: "IX_QrCodeDesigns_ProjectId",
                table: "QRCodeDesigns",
                newName: "IX_QRCodeDesigns_ProjectId");

            migrationBuilder.RenameIndex(
                name: "IX_QrCodeDesigns_LogoAssetId",
                table: "QRCodeDesigns",
                newName: "IX_QRCodeDesigns_LogoAssetId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_QRCodeDesigns",
                table: "QRCodeDesigns",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Events_QRCodeDesigns_QRCodeId",
                table: "Events",
                column: "QRCodeId",
                principalTable: "QRCodeDesigns",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QRCodeDesigns_Assets_LogoAssetId",
                table: "QRCodeDesigns",
                column: "LogoAssetId",
                principalTable: "Assets",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QRCodeDesigns_Projects_ProjectId",
                table: "QRCodeDesigns",
                column: "ProjectId",
                principalTable: "Projects",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QRCodeDesigns_ShortLinks_ShortLinkId",
                table: "QRCodeDesigns",
                column: "ShortLinkId",
                principalTable: "ShortLinks",
                principalColumn: "Id",
                onDelete: ReferentialAction.SetNull);

            migrationBuilder.AddForeignKey(
                name: "FK_QRCodeDesigns_Workspaces_WorkspaceId",
                table: "QRCodeDesigns",
                column: "WorkspaceId",
                principalTable: "Workspaces",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
