using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace wispro.sp.api.Migrations
{
    public partial class workflowmodify : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<DateTime>(
                name: "CreateTime",
                table: "Workflow",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<int>(
                name: "CreateUserId",
                table: "Workflow",
                type: "int",
                nullable: false,
                defaultValue: 0);

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

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

            migrationBuilder.AddColumn<string>(
                name: "Memo",
                table: "Workflow",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "DoItemMemo",
                table: "PerformanceItem",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(500)",
                oldMaxLength: 500,
                oldNullable: true);

            migrationBuilder.InsertData(
                table: "BasePointRule",
                columns: new[] { "Id", "PointExpress", "Priority", "Rule", "Type" },
                values: new object[] { 138, "0.2", 85, "p.DoItem==\"处理审查意见\" && p.ApplicationType==\"发明\" && p.DoItemCoefficient==\"形式\" && (p.PreOastaffId != null && p.ItemStaffs.Where<ItemStaff>(s => s.DoPersonId == p.PreOastaffId).Count() == 0)", "OA" });

            migrationBuilder.InsertData(
                table: "BasePointRule",
                columns: new[] { "Id", "PointExpress", "Priority", "Rule", "Type" },
                values: new object[] { 139, "0.5", 84, "p.DoItem==\"处理审查意见\" && p.ApplicationType==\"发明\" && p.DoItemCoefficient==\"实质\" && (p.PreOastaffId != null && p.ItemStaffs.Where<ItemStaff>(s => s.DoPersonId == p.PreOastaffId).Count() == 0)", "OA" });

            migrationBuilder.InsertData(
                table: "BasePointRule",
                columns: new[] { "Id", "PointExpress", "Priority", "Rule", "Type" },
                values: new object[] { 140, "0.3", 83, "p.DoItem==\"处理审查意见\" && p.ApplicationType==\"发明\" && p.DoItemCoefficient==\"非实质\"  && (p.PreOastaffId != null && p.ItemStaffs.Where<ItemStaff>(s => s.DoPersonId == p.PreOastaffId).Count() == 0)", "OA" });

            migrationBuilder.CreateIndex(
                name: "IX_Workflow_CreateUserId",
                table: "Workflow",
                column: "CreateUserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Workflow_Staff_CreateUserId",
                table: "Workflow",
                column: "CreateUserId",
                principalTable: "Staff",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

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

            migrationBuilder.DropIndex(
                name: "IX_Workflow_CreateUserId",
                table: "Workflow");

            migrationBuilder.DeleteData(
                table: "BasePointRule",
                keyColumn: "Id",
                keyValue: 138);

            migrationBuilder.DeleteData(
                table: "BasePointRule",
                keyColumn: "Id",
                keyValue: 139);

            migrationBuilder.DeleteData(
                table: "BasePointRule",
                keyColumn: "Id",
                keyValue: 140);

            migrationBuilder.DropColumn(
                name: "CreateTime",
                table: "Workflow");

            migrationBuilder.DropColumn(
                name: "CreateUserId",
                table: "Workflow");

            migrationBuilder.DropColumn(
                name: "EffectivrDate",
                table: "Workflow");

            migrationBuilder.DropColumn(
                name: "ExpirationDate",
                table: "Workflow");

            migrationBuilder.DropColumn(
                name: "Memo",
                table: "Workflow");

            migrationBuilder.AlterColumn<string>(
                name: "DoItemMemo",
                table: "PerformanceItem",
                type: "nvarchar(500)",
                maxLength: 500,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);
        }
    }
}
