using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PSTW_CentralSystem.Migrations
{
    /// <inheritdoc />
    public partial class UpdateDatabaseChanges : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "SupplierName",
                table: "Suppliers",
                newName: "SupplierCompName");

            migrationBuilder.RenameColumn(
                name: "SupplierGender",
                table: "Suppliers",
                newName: "SupplierAddress");

            migrationBuilder.AlterColumn<string>(
                name: "SupplierPhoneNo",
                table: "Suppliers",
                type: "longtext",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "longtext")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "SupplierEmail",
                table: "Suppliers",
                type: "longtext",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "longtext")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "SupplierPIC",
                table: "Suppliers",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "ProductShortName",
                table: "Products",
                type: "longtext",
                nullable: false)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "PartNumber",
                table: "Items",
                type: "longtext",
                nullable: false)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Request",
                columns: table => new
                {
                    requestId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    remark = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    status = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    requestDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    approvalDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Request", x => x.requestId);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "AspNetUsers",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
                values: new object[] { "6b8e8dbd-4380-4e8c-aa0b-1c1fffc3059c", "AQAAAAIAAYagAAAAEFKtr2LZjKgfLzY44m8cVW4qpdwci45lnh/t3ioymIh6Ib6c85ne3QGfnUAyERwMWg==", "79e606c8-032b-426b-8fb2-7727b93823eb" });

            migrationBuilder.UpdateData(
                table: "AspNetUsers",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
                values: new object[] { "8bf46c63-d7df-4ac5-bab2-fc15fe881302", "AQAAAAIAAYagAAAAEB/4JzIPKQK76gM4+Ddc948BoBumC8oa2Ya4odgM4r6P+LNaWRaLOaFG4bp0Iya9Sg==", "5ac5ec31-c25f-4a7a-8057-664ecdf76108" });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Request");

            migrationBuilder.DropColumn(
                name: "SupplierPIC",
                table: "Suppliers");

            migrationBuilder.DropColumn(
                name: "ProductShortName",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "PartNumber",
                table: "Items");

            migrationBuilder.RenameColumn(
                name: "SupplierCompName",
                table: "Suppliers",
                newName: "SupplierName");

            migrationBuilder.RenameColumn(
                name: "SupplierAddress",
                table: "Suppliers",
                newName: "SupplierGender");

            migrationBuilder.UpdateData(
                table: "Suppliers",
                keyColumn: "SupplierPhoneNo",
                keyValue: null,
                column: "SupplierPhoneNo",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "SupplierPhoneNo",
                table: "Suppliers",
                type: "longtext",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "Suppliers",
                keyColumn: "SupplierEmail",
                keyValue: null,
                column: "SupplierEmail",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "SupplierEmail",
                table: "Suppliers",
                type: "longtext",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "AspNetUsers",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
                values: new object[] { "4c8e81ae-2e43-4f98-82a0-4d7c4aa6d011", "AQAAAAIAAYagAAAAEKr0d9Fe168hXvdX6+oJvbfo2QHFsp8i/EQjhLbkWRn/yvKImJa6XzZ5KJ6qohTE1w==", "2219ec34-d4a0-496b-a7d7-e6c5d7b2a222" });

            migrationBuilder.UpdateData(
                table: "AspNetUsers",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
                values: new object[] { "bcc1500e-9ae2-4704-9997-dbe646d2fa7a", "AQAAAAIAAYagAAAAEE3CUAWzIeL592V5xPyAD5ciHe8OGtvbNHhU6UNafDMT/+0R77o6UCDj/K8wc0j0Xw==", "7c582e0d-8237-4605-8fec-449bbe78f6c9" });
        }
    }
}
