using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

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

            migrationBuilder.AlterColumn<string>(
                name: "OriginalName",
                table: "UserTaskAttachments",
                type: "nvarchar(250)",
                maxLength: 250,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(250)",
                oldMaxLength: 250);

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

            migrationBuilder.InsertData(
                table: "AttachmentTypes",
                columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
                values: new object[,]
                {
                    { 3L, false, "شهادة التعليم", "Education Certification" },
                    { 4L, false, "شهادة الخبرة", "Experience Certification" },
                    { 5L, false, "شهادة الاحتراف", "Professional Certification" }
                });

            migrationBuilder.AddForeignKey(
                name: "FK_UserTaskAttachments_AttachmentTypes_AttachmentTypeId",
                table: "UserTaskAttachments",
                column: "AttachmentTypeId",
                principalTable: "AttachmentTypes",
                principalColumn: "Id");
        }

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

            migrationBuilder.DeleteData(
                table: "AttachmentTypes",
                keyColumn: "Id",
                keyValue: 3L);

            migrationBuilder.DeleteData(
                table: "AttachmentTypes",
                keyColumn: "Id",
                keyValue: 4L);

            migrationBuilder.DeleteData(
                table: "AttachmentTypes",
                keyColumn: "Id",
                keyValue: 5L);

            migrationBuilder.AlterColumn<string>(
                name: "OriginalName",
                table: "UserTaskAttachments",
                type: "nvarchar(250)",
                maxLength: 250,
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "nvarchar(250)",
                oldMaxLength: 250,
                oldNullable: true);

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

            migrationBuilder.AddForeignKey(
                name: "FK_UserTaskAttachments_AttachmentTypes_AttachmentTypeId",
                table: "UserTaskAttachments",
                column: "AttachmentTypeId",
                principalTable: "AttachmentTypes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
