using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace NetinaShop.Repository.Migrations
{
    /// <inheritdoc />
    public partial class ChangeOrderUserIdToCustomerId : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Orders_Customers_UserId",
                schema: "public",
                table: "Orders");

            migrationBuilder.RenameColumn(
                name: "UserId",
                schema: "public",
                table: "Orders",
                newName: "CustomerId");

            migrationBuilder.RenameIndex(
                name: "IX_Orders_UserId",
                schema: "public",
                table: "Orders",
                newName: "IX_Orders_CustomerId");

            migrationBuilder.AddForeignKey(
                name: "FK_Orders_Customers_CustomerId",
                schema: "public",
                table: "Orders",
                column: "CustomerId",
                principalSchema: "public",
                principalTable: "Customers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Orders_Customers_CustomerId",
                schema: "public",
                table: "Orders");

            migrationBuilder.RenameColumn(
                name: "CustomerId",
                schema: "public",
                table: "Orders",
                newName: "UserId");

            migrationBuilder.RenameIndex(
                name: "IX_Orders_CustomerId",
                schema: "public",
                table: "Orders",
                newName: "IX_Orders_UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Orders_Customers_UserId",
                schema: "public",
                table: "Orders",
                column: "UserId",
                principalSchema: "public",
                principalTable: "Customers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
