using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MTWorkHR.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class altrOrder : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "DateActioned",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "DateRequested",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "IsApproved",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "IsCancelled",
                table: "OrderRequests");

            migrationBuilder.AlterColumn<DateTime>(
                name: "EndDate",
                table: "OrderRequests",
                type: "datetime2",
                nullable: true,
                oldClrType: typeof(DateTime),
                oldType: "datetime2");

            migrationBuilder.AddColumn<int>(
                name: "CityId",
                table: "OrderRequests",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "CountryId",
                table: "OrderRequests",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<long>(
                name: "LeaveTypeId",
                table: "OrderRequests",
                type: "bigint",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "OrderStatus",
                table: "OrderRequests",
                type: "int",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "LeaveTypes",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
                    UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    NameAr = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    NameEn = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DefaultDays = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LeaveTypes", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OrderRequests_LeaveTypeId",
                table: "OrderRequests",
                column: "LeaveTypeId");

            migrationBuilder.AddForeignKey(
                name: "FK_OrderRequests_LeaveTypes_LeaveTypeId",
                table: "OrderRequests",
                column: "LeaveTypeId",
                principalTable: "LeaveTypes",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropTable(
                name: "LeaveTypes");

            migrationBuilder.DropIndex(
                name: "IX_OrderRequests_LeaveTypeId",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "CityId",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "CountryId",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "LeaveTypeId",
                table: "OrderRequests");

            migrationBuilder.DropColumn(
                name: "OrderStatus",
                table: "OrderRequests");

            migrationBuilder.AlterColumn<DateTime>(
                name: "EndDate",
                table: "OrderRequests",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                oldClrType: typeof(DateTime),
                oldType: "datetime2",
                oldNullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "DateActioned",
                table: "OrderRequests",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "DateRequested",
                table: "OrderRequests",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<bool>(
                name: "IsApproved",
                table: "OrderRequests",
                type: "bit",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsCancelled",
                table: "OrderRequests",
                type: "bit",
                nullable: false,
                defaultValue: false);
        }
    }
}
