using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddDiscountShopSystem : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Categorys_Categorys_ParentId",
                schema: "CMS",
                table: "Categorys");

            migrationBuilder.DropForeignKey(
                name: "FK_DayaLoanContracts_Transactionss_TransactionId",
                schema: "CMS",
                table: "DayaLoanContracts");

            migrationBuilder.DropForeignKey(
                name: "FK_FactorDetailss_Productss_ProductId",
                schema: "CMS",
                table: "FactorDetailss");

            migrationBuilder.DropForeignKey(
                name: "FK_FactorDetailss_UserOrders_OrderId",
                schema: "CMS",
                table: "FactorDetailss");

            migrationBuilder.DropForeignKey(
                name: "FK_ManualPayments_Transactionss_TransactionId",
                schema: "CMS",
                table: "ManualPayments");

            migrationBuilder.DropForeignKey(
                name: "FK_UserAddresss_Users_UserId",
                schema: "CMS",
                table: "UserAddresss");

            migrationBuilder.DropForeignKey(
                name: "FK_UserOrders_Transactionss_TransactionId",
                schema: "CMS",
                table: "UserOrders");

            migrationBuilder.DropForeignKey(
                name: "FK_UserOrders_UserAddresss_UserAddressId",
                schema: "CMS",
                table: "UserOrders");

            migrationBuilder.DropForeignKey(
                name: "FK_UserPackagePurchases_Transactionss_TransactionId",
                schema: "CMS",
                table: "UserPackagePurchases");

            migrationBuilder.DropTable(
                name: "ProductGalleryss",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "PruductCategorys",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "PruductTags",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "Transactionss",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "UserCartss",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "ProductImagess",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "Productss",
                schema: "CMS");

            migrationBuilder.DropPrimaryKey(
                name: "PK_UserAddresss",
                schema: "CMS",
                table: "UserAddresss");

            migrationBuilder.DropPrimaryKey(
                name: "PK_FactorDetailss",
                schema: "CMS",
                table: "FactorDetailss");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Categorys",
                schema: "CMS",
                table: "Categorys");

            migrationBuilder.RenameTable(
                name: "UserAddresss",
                schema: "CMS",
                newName: "UserAddresses",
                newSchema: "CMS");

            migrationBuilder.RenameTable(
                name: "FactorDetailss",
                schema: "CMS",
                newName: "FactorDetails",
                newSchema: "CMS");

            migrationBuilder.RenameTable(
                name: "Categorys",
                schema: "CMS",
                newName: "Categories",
                newSchema: "CMS");

            migrationBuilder.RenameIndex(
                name: "IX_UserAddresss_UserId",
                schema: "CMS",
                table: "UserAddresses",
                newName: "IX_UserAddresses_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_FactorDetailss_ProductId",
                schema: "CMS",
                table: "FactorDetails",
                newName: "IX_FactorDetails_ProductId");

            migrationBuilder.RenameIndex(
                name: "IX_FactorDetailss_OrderId",
                schema: "CMS",
                table: "FactorDetails",
                newName: "IX_FactorDetails_OrderId");

            migrationBuilder.RenameIndex(
                name: "IX_Categorys_ParentId",
                schema: "CMS",
                table: "Categories",
                newName: "IX_Categories_ParentId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_UserAddresses",
                schema: "CMS",
                table: "UserAddresses",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_FactorDetails",
                schema: "CMS",
                table: "FactorDetails",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Categories",
                schema: "CMS",
                table: "Categories",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "DiscountCategories",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
                    ImagePath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    ParentCategoryId = table.Column<long>(type: "bigint", nullable: true),
                    SortOrder = table.Column<int>(type: "int", nullable: false),
                    IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: 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_DiscountCategories", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DiscountCategories_DiscountCategories_ParentCategoryId",
                        column: x => x.ParentCategoryId,
                        principalSchema: "CMS",
                        principalTable: "DiscountCategories",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "DiscountProducts",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    ShortInfomation = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    FullInformation = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false),
                    Price = table.Column<long>(type: "bigint", nullable: false),
                    MaxDiscountPercent = table.Column<int>(type: "int", nullable: false),
                    Rate = table.Column<int>(type: "int", nullable: false),
                    ImagePath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    ThumbnailPath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    SaleCount = table.Column<int>(type: "int", nullable: false),
                    ViewCount = table.Column<int>(type: "int", nullable: false),
                    RemainingCount = table.Column<int>(type: "int", nullable: false),
                    IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: 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_DiscountProducts", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProductImages",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ImagePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ImageThumbnailPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    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_ProductImages", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Products",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ShortInfomation = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FullInformation = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Price = table.Column<long>(type: "bigint", nullable: false),
                    Discount = table.Column<int>(type: "int", nullable: false),
                    Rate = table.Column<int>(type: "int", nullable: false),
                    ImagePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ThumbnailPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SaleCount = table.Column<int>(type: "int", nullable: false),
                    ViewCount = table.Column<int>(type: "int", nullable: false),
                    RemainingCount = table.Column<int>(type: "int", nullable: false),
                    IsClubExclusive = table.Column<bool>(type: "bit", nullable: false),
                    ClubDiscountPercent = table.Column<int>(type: "int", nullable: false),
                    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_Products", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Transactions",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Amount = table.Column<long>(type: "bigint", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PaymentStatus = table.Column<int>(type: "int", nullable: false),
                    PaymentDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    RefId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Type = table.Column<int>(type: "int", nullable: false),
                    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_Transactions", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "DiscountProductCategories",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    CategoryId = table.Column<long>(type: "bigint", nullable: false),
                    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_DiscountProductCategories", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DiscountProductCategories_DiscountCategories_CategoryId",
                        column: x => x.CategoryId,
                        principalSchema: "CMS",
                        principalTable: "DiscountCategories",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_DiscountProductCategories_DiscountProducts_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "DiscountProducts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "DiscountShoppingCarts",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserId = table.Column<long>(type: "bigint", nullable: false),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    Count = table.Column<int>(type: "int", nullable: false),
                    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_DiscountShoppingCarts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DiscountShoppingCarts_DiscountProducts_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "DiscountProducts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_DiscountShoppingCarts_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "CMS",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ProductCategories",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    CategoryId = table.Column<long>(type: "bigint", nullable: false),
                    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_ProductCategories", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductCategories_Categories_CategoryId",
                        column: x => x.CategoryId,
                        principalSchema: "CMS",
                        principalTable: "Categories",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductCategories_Products_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ProductGalleries",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductImageId = table.Column<long>(type: "bigint", nullable: false),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    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_ProductGalleries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductGalleries_ProductImages_ProductImageId",
                        column: x => x.ProductImageId,
                        principalSchema: "CMS",
                        principalTable: "ProductImages",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductGalleries_Products_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ProductTags",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    TagId = table.Column<long>(type: "bigint", nullable: false),
                    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_ProductTags", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductTags_Products_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductTags_Tags_TagId",
                        column: x => x.TagId,
                        principalSchema: "CMS",
                        principalTable: "Tags",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "UserCarts",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    UserId = table.Column<long>(type: "bigint", nullable: false),
                    Count = table.Column<int>(type: "int", nullable: false),
                    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_UserCarts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserCarts_Products_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_UserCarts_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "CMS",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "DiscountOrders",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserId = table.Column<long>(type: "bigint", nullable: false),
                    TotalAmount = table.Column<long>(type: "bigint", nullable: false),
                    DiscountBalanceUsed = table.Column<long>(type: "bigint", nullable: false),
                    GatewayAmountPaid = table.Column<long>(type: "bigint", nullable: false),
                    VatAmount = table.Column<long>(type: "bigint", nullable: false),
                    PaymentStatus = table.Column<int>(type: "int", nullable: false),
                    PaymentDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    TransactionId = table.Column<long>(type: "bigint", nullable: true),
                    UserAddressId = table.Column<long>(type: "bigint", nullable: false),
                    DeliveryStatus = table.Column<int>(type: "int", nullable: false),
                    TrackingCode = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    DeliveryDescription = table.Column<string>(type: "nvarchar(500)", maxLength: 500, 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_DiscountOrders", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DiscountOrders_Transactions_TransactionId",
                        column: x => x.TransactionId,
                        principalSchema: "CMS",
                        principalTable: "Transactions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_DiscountOrders_UserAddresses_UserAddressId",
                        column: x => x.UserAddressId,
                        principalSchema: "CMS",
                        principalTable: "UserAddresses",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_DiscountOrders_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "CMS",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "DiscountOrderDetails",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DiscountOrderId = table.Column<long>(type: "bigint", nullable: false),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    Count = table.Column<int>(type: "int", nullable: false),
                    UnitPrice = table.Column<long>(type: "bigint", nullable: false),
                    DiscountPercentUsed = table.Column<int>(type: "int", nullable: false),
                    DiscountAmount = table.Column<long>(type: "bigint", nullable: false),
                    FinalPrice = table.Column<long>(type: "bigint", nullable: false),
                    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_DiscountOrderDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DiscountOrderDetails_DiscountOrders_DiscountOrderId",
                        column: x => x.DiscountOrderId,
                        principalSchema: "CMS",
                        principalTable: "DiscountOrders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_DiscountOrderDetails_DiscountProducts_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "DiscountProducts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_DiscountCategories_ParentCategoryId",
                schema: "CMS",
                table: "DiscountCategories",
                column: "ParentCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountOrderDetails_DiscountOrderId",
                schema: "CMS",
                table: "DiscountOrderDetails",
                column: "DiscountOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountOrderDetails_ProductId",
                schema: "CMS",
                table: "DiscountOrderDetails",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountOrders_TransactionId",
                schema: "CMS",
                table: "DiscountOrders",
                column: "TransactionId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountOrders_UserAddressId",
                schema: "CMS",
                table: "DiscountOrders",
                column: "UserAddressId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountOrders_UserId",
                schema: "CMS",
                table: "DiscountOrders",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountProductCategories_CategoryId",
                schema: "CMS",
                table: "DiscountProductCategories",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountProductCategories_ProductId_CategoryId",
                schema: "CMS",
                table: "DiscountProductCategories",
                columns: new[] { "ProductId", "CategoryId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_DiscountShoppingCarts_ProductId",
                schema: "CMS",
                table: "DiscountShoppingCarts",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_DiscountShoppingCarts_UserId_ProductId",
                schema: "CMS",
                table: "DiscountShoppingCarts",
                columns: new[] { "UserId", "ProductId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_ProductCategories_CategoryId",
                schema: "CMS",
                table: "ProductCategories",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductCategories_ProductId",
                schema: "CMS",
                table: "ProductCategories",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductGalleries_ProductId",
                schema: "CMS",
                table: "ProductGalleries",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductGalleries_ProductImageId",
                schema: "CMS",
                table: "ProductGalleries",
                column: "ProductImageId");

            migrationBuilder.CreateIndex(
                name: "IX_Products_IsClubExclusive",
                schema: "CMS",
                table: "Products",
                column: "IsClubExclusive");

            migrationBuilder.CreateIndex(
                name: "IX_ProductTags_ProductId",
                schema: "CMS",
                table: "ProductTags",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductTags_TagId",
                schema: "CMS",
                table: "ProductTags",
                column: "TagId");

            migrationBuilder.CreateIndex(
                name: "IX_UserCarts_ProductId",
                schema: "CMS",
                table: "UserCarts",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_UserCarts_UserId",
                schema: "CMS",
                table: "UserCarts",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Categories_Categories_ParentId",
                schema: "CMS",
                table: "Categories",
                column: "ParentId",
                principalSchema: "CMS",
                principalTable: "Categories",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_DayaLoanContracts_Transactions_TransactionId",
                schema: "CMS",
                table: "DayaLoanContracts",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactions",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_FactorDetails_Products_ProductId",
                schema: "CMS",
                table: "FactorDetails",
                column: "ProductId",
                principalSchema: "CMS",
                principalTable: "Products",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_FactorDetails_UserOrders_OrderId",
                schema: "CMS",
                table: "FactorDetails",
                column: "OrderId",
                principalSchema: "CMS",
                principalTable: "UserOrders",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ManualPayments_Transactions_TransactionId",
                schema: "CMS",
                table: "ManualPayments",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_UserAddresses_Users_UserId",
                schema: "CMS",
                table: "UserAddresses",
                column: "UserId",
                principalSchema: "CMS",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UserOrders_Transactions_TransactionId",
                schema: "CMS",
                table: "UserOrders",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactions",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_UserOrders_UserAddresses_UserAddressId",
                schema: "CMS",
                table: "UserOrders",
                column: "UserAddressId",
                principalSchema: "CMS",
                principalTable: "UserAddresses",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_UserPackagePurchases_Transactions_TransactionId",
                schema: "CMS",
                table: "UserPackagePurchases",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Categories_Categories_ParentId",
                schema: "CMS",
                table: "Categories");

            migrationBuilder.DropForeignKey(
                name: "FK_DayaLoanContracts_Transactions_TransactionId",
                schema: "CMS",
                table: "DayaLoanContracts");

            migrationBuilder.DropForeignKey(
                name: "FK_FactorDetails_Products_ProductId",
                schema: "CMS",
                table: "FactorDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_FactorDetails_UserOrders_OrderId",
                schema: "CMS",
                table: "FactorDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_ManualPayments_Transactions_TransactionId",
                schema: "CMS",
                table: "ManualPayments");

            migrationBuilder.DropForeignKey(
                name: "FK_UserAddresses_Users_UserId",
                schema: "CMS",
                table: "UserAddresses");

            migrationBuilder.DropForeignKey(
                name: "FK_UserOrders_Transactions_TransactionId",
                schema: "CMS",
                table: "UserOrders");

            migrationBuilder.DropForeignKey(
                name: "FK_UserOrders_UserAddresses_UserAddressId",
                schema: "CMS",
                table: "UserOrders");

            migrationBuilder.DropForeignKey(
                name: "FK_UserPackagePurchases_Transactions_TransactionId",
                schema: "CMS",
                table: "UserPackagePurchases");

            migrationBuilder.DropTable(
                name: "DiscountOrderDetails",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "DiscountProductCategories",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "DiscountShoppingCarts",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "ProductCategories",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "ProductGalleries",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "ProductTags",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "UserCarts",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "DiscountOrders",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "DiscountCategories",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "DiscountProducts",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "ProductImages",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "Products",
                schema: "CMS");

            migrationBuilder.DropTable(
                name: "Transactions",
                schema: "CMS");

            migrationBuilder.DropPrimaryKey(
                name: "PK_UserAddresses",
                schema: "CMS",
                table: "UserAddresses");

            migrationBuilder.DropPrimaryKey(
                name: "PK_FactorDetails",
                schema: "CMS",
                table: "FactorDetails");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Categories",
                schema: "CMS",
                table: "Categories");

            migrationBuilder.RenameTable(
                name: "UserAddresses",
                schema: "CMS",
                newName: "UserAddresss",
                newSchema: "CMS");

            migrationBuilder.RenameTable(
                name: "FactorDetails",
                schema: "CMS",
                newName: "FactorDetailss",
                newSchema: "CMS");

            migrationBuilder.RenameTable(
                name: "Categories",
                schema: "CMS",
                newName: "Categorys",
                newSchema: "CMS");

            migrationBuilder.RenameIndex(
                name: "IX_UserAddresses_UserId",
                schema: "CMS",
                table: "UserAddresss",
                newName: "IX_UserAddresss_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_FactorDetails_ProductId",
                schema: "CMS",
                table: "FactorDetailss",
                newName: "IX_FactorDetailss_ProductId");

            migrationBuilder.RenameIndex(
                name: "IX_FactorDetails_OrderId",
                schema: "CMS",
                table: "FactorDetailss",
                newName: "IX_FactorDetailss_OrderId");

            migrationBuilder.RenameIndex(
                name: "IX_Categories_ParentId",
                schema: "CMS",
                table: "Categorys",
                newName: "IX_Categorys_ParentId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_UserAddresss",
                schema: "CMS",
                table: "UserAddresss",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_FactorDetailss",
                schema: "CMS",
                table: "FactorDetailss",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Categorys",
                schema: "CMS",
                table: "Categorys",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "ProductImagess",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ImagePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ImageThumbnailPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductImagess", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Productss",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ClubDiscountPercent = table.Column<int>(type: "int", nullable: false),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Discount = table.Column<int>(type: "int", nullable: false),
                    FullInformation = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ImagePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsClubExclusive = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Price = table.Column<long>(type: "bigint", nullable: false),
                    Rate = table.Column<int>(type: "int", nullable: false),
                    RemainingCount = table.Column<int>(type: "int", nullable: false),
                    SaleCount = table.Column<int>(type: "int", nullable: false),
                    ShortInfomation = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ThumbnailPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ViewCount = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Productss", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Transactionss",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Amount = table.Column<long>(type: "bigint", nullable: false),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PaymentDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    PaymentStatus = table.Column<int>(type: "int", nullable: false),
                    RefId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Type = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Transactionss", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProductGalleryss",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    ProductImageId = table.Column<long>(type: "bigint", nullable: false),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductGalleryss", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductGalleryss_ProductImagess_ProductImageId",
                        column: x => x.ProductImageId,
                        principalSchema: "CMS",
                        principalTable: "ProductImagess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductGalleryss_Productss_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Productss",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PruductCategorys",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CategoryId = table.Column<long>(type: "bigint", nullable: false),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PruductCategorys", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PruductCategorys_Categorys_CategoryId",
                        column: x => x.CategoryId,
                        principalSchema: "CMS",
                        principalTable: "Categorys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PruductCategorys_Productss_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Productss",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PruductTags",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    TagId = table.Column<long>(type: "bigint", nullable: false),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PruductTags", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PruductTags_Productss_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Productss",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PruductTags_Tags_TagId",
                        column: x => x.TagId,
                        principalSchema: "CMS",
                        principalTable: "Tags",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "UserCartss",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<long>(type: "bigint", nullable: false),
                    UserId = table.Column<long>(type: "bigint", nullable: false),
                    Count = table.Column<int>(type: "int", nullable: false),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserCartss", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserCartss_Productss_ProductId",
                        column: x => x.ProductId,
                        principalSchema: "CMS",
                        principalTable: "Productss",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_UserCartss_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "CMS",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ProductGalleryss_ProductId",
                schema: "CMS",
                table: "ProductGalleryss",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductGalleryss_ProductImageId",
                schema: "CMS",
                table: "ProductGalleryss",
                column: "ProductImageId");

            migrationBuilder.CreateIndex(
                name: "IX_Products_IsClubExclusive",
                schema: "CMS",
                table: "Productss",
                column: "IsClubExclusive");

            migrationBuilder.CreateIndex(
                name: "IX_PruductCategorys_CategoryId",
                schema: "CMS",
                table: "PruductCategorys",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_PruductCategorys_ProductId",
                schema: "CMS",
                table: "PruductCategorys",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_PruductTags_ProductId",
                schema: "CMS",
                table: "PruductTags",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_PruductTags_TagId",
                schema: "CMS",
                table: "PruductTags",
                column: "TagId");

            migrationBuilder.CreateIndex(
                name: "IX_UserCartss_ProductId",
                schema: "CMS",
                table: "UserCartss",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_UserCartss_UserId",
                schema: "CMS",
                table: "UserCartss",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Categorys_Categorys_ParentId",
                schema: "CMS",
                table: "Categorys",
                column: "ParentId",
                principalSchema: "CMS",
                principalTable: "Categorys",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_DayaLoanContracts_Transactionss_TransactionId",
                schema: "CMS",
                table: "DayaLoanContracts",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactionss",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_FactorDetailss_Productss_ProductId",
                schema: "CMS",
                table: "FactorDetailss",
                column: "ProductId",
                principalSchema: "CMS",
                principalTable: "Productss",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_FactorDetailss_UserOrders_OrderId",
                schema: "CMS",
                table: "FactorDetailss",
                column: "OrderId",
                principalSchema: "CMS",
                principalTable: "UserOrders",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ManualPayments_Transactionss_TransactionId",
                schema: "CMS",
                table: "ManualPayments",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactionss",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_UserAddresss_Users_UserId",
                schema: "CMS",
                table: "UserAddresss",
                column: "UserId",
                principalSchema: "CMS",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UserOrders_Transactionss_TransactionId",
                schema: "CMS",
                table: "UserOrders",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactionss",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_UserOrders_UserAddresss_UserAddressId",
                schema: "CMS",
                table: "UserOrders",
                column: "UserAddressId",
                principalSchema: "CMS",
                principalTable: "UserAddresss",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_UserPackagePurchases_Transactionss_TransactionId",
                schema: "CMS",
                table: "UserPackagePurchases",
                column: "TransactionId",
                principalSchema: "CMS",
                principalTable: "Transactionss",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
