using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddPaymentTransactionTable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "PaymentTransactions",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    GatewayProvider = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MerchantId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    Amount = table.Column<long>(type: "bigint", nullable: false),
                    CallbackUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    Mobile = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    UserId = table.Column<long>(type: "bigint", nullable: true),
                    RequestStatusCode = table.Column<int>(type: "int", nullable: true),
                    RequestStatusMessage = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Authority = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    PaymentStatus = table.Column<bool>(type: "bit", nullable: false),
                    VerificationStatusCode = table.Column<int>(type: "int", nullable: true),
                    VerificationStatusMessage = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CardHash = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    CardPan = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    RefId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    TransactionId = table.Column<long>(type: "bigint", nullable: true),
                    OrderId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PaymentTransactions", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_PaymentTransactions_Authority",
                schema: "CMS",
                table: "PaymentTransactions",
                column: "Authority");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentTransactions_GatewayProvider",
                schema: "CMS",
                table: "PaymentTransactions",
                column: "GatewayProvider");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentTransactions_RefId",
                schema: "CMS",
                table: "PaymentTransactions",
                column: "RefId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentTransactions_TransactionId",
                schema: "CMS",
                table: "PaymentTransactions",
                column: "TransactionId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentTransactions_UserId",
                schema: "CMS",
                table: "PaymentTransactions",
                column: "UserId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "PaymentTransactions",
                schema: "CMS");
        }
    }
}
