using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SolutionErp.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddApprovalWorkflowToContract : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "ApprovalWorkflowId",
                table: "Contracts",
                type: "uniqueidentifier",
                nullable: true);

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

            migrationBuilder.CreateIndex(
                name: "IX_Contracts_ApprovalWorkflowId",
                table: "Contracts",
                column: "ApprovalWorkflowId");

            migrationBuilder.AddForeignKey(
                name: "FK_Contracts_ApprovalWorkflows_ApprovalWorkflowId",
                table: "Contracts",
                column: "ApprovalWorkflowId",
                principalTable: "ApprovalWorkflows",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

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

            migrationBuilder.DropIndex(
                name: "IX_Contracts_ApprovalWorkflowId",
                table: "Contracts");

            migrationBuilder.DropColumn(
                name: "ApprovalWorkflowId",
                table: "Contracts");

            migrationBuilder.DropColumn(
                name: "CurrentApprovalLevelOrder",
                table: "Contracts");
        }
    }
}
