using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MTWorkHR.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class altrProjectTeam : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ProjectTeam_Projects_TeamId",
                table: "ProjectTeam");

            migrationBuilder.DropIndex(
                name: "IX_ProjectTeam_TeamId",
                table: "ProjectTeam");

            migrationBuilder.DropColumn(
                name: "AssignedUserId",
                table: "ProjectTeam");

            migrationBuilder.RenameColumn(
                name: "AssignedUserName",
                table: "ProjectTeam",
                newName: "TeamName");

            migrationBuilder.AlterColumn<long>(
                name: "TeamId",
                table: "ProjectTeam",
                type: "bigint",
                nullable: false,
                defaultValue: 0L,
                oldClrType: typeof(long),
                oldType: "bigint",
                oldNullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_ProjectTeam_ProjectId",
                table: "ProjectTeam",
                column: "ProjectId");

            migrationBuilder.AddForeignKey(
                name: "FK_ProjectTeam_Projects_ProjectId",
                table: "ProjectTeam",
                column: "ProjectId",
                principalTable: "Projects",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

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

            migrationBuilder.DropIndex(
                name: "IX_ProjectTeam_ProjectId",
                table: "ProjectTeam");

            migrationBuilder.RenameColumn(
                name: "TeamName",
                table: "ProjectTeam",
                newName: "AssignedUserName");

            migrationBuilder.AlterColumn<long>(
                name: "TeamId",
                table: "ProjectTeam",
                type: "bigint",
                nullable: true,
                oldClrType: typeof(long),
                oldType: "bigint");

            migrationBuilder.AddColumn<string>(
                name: "AssignedUserId",
                table: "ProjectTeam",
                type: "nvarchar(max)",
                nullable: false,
                defaultValue: "");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectTeam_TeamId",
                table: "ProjectTeam",
                column: "TeamId");

            migrationBuilder.AddForeignKey(
                name: "FK_ProjectTeam_Projects_TeamId",
                table: "ProjectTeam",
                column: "TeamId",
                principalTable: "Projects",
                principalColumn: "Id");
        }
    }
}
