using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Ropin.Inspection.Model.Migrations
{
    public partial class EditArea : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<Guid>(
                name: "C_StoreCode",
                table: "TPNT_Area",
                type: "char(36)",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "varchar(50) CHARACTER SET utf8mb4",
                oldMaxLength: 50);

            migrationBuilder.AlterColumn<string>(
                name: "C_Remark",
                table: "TPNT_Area",
                type: "varchar(1024) CHARACTER SET utf8mb4",
                maxLength: 1024,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(500) CHARACTER SET utf8mb4",
                oldMaxLength: 500,
                oldNullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_TPNT_Area_C_StoreCode",
                table: "TPNT_Area",
                column: "C_StoreCode");

            migrationBuilder.AddForeignKey(
                name: "FK_TPNT_Area_TPNT_Store_C_StoreCode",
                table: "TPNT_Area",
                column: "C_StoreCode",
                principalTable: "TPNT_Store",
                principalColumn: "C_ID",
                onDelete: ReferentialAction.Restrict);
           
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_TPNT_Area_TPNT_Store_C_StoreCode",
                table: "TPNT_Area");

            migrationBuilder.DropIndex(
                name: "IX_TPNT_Area_C_StoreCode",
                table: "TPNT_Area");

            migrationBuilder.AlterColumn<string>(
                name: "C_StoreCode",
                table: "TPNT_Area",
                type: "varchar(50) CHARACTER SET utf8mb4",
                maxLength: 50,
                nullable: false,
                oldClrType: typeof(Guid),
                oldType: "char(36)");

            migrationBuilder.AlterColumn<string>(
                name: "C_Remark",
                table: "TPNT_Area",
                type: "varchar(500) CHARACTER SET utf8mb4",
                maxLength: 500,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(1024) CHARACTER SET utf8mb4",
                oldMaxLength: 1024,
                oldNullable: true);
        }
    }
}