using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace NetinaShop.Repository.Migrations
{
    /// <inheritdoc />
    public partial class EditShippingAddAddressId : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Address",
                schema: "public",
                table: "OrderDeliveries");

            migrationBuilder.DropColumn(
                name: "PostalCode",
                schema: "public",
                table: "OrderDeliveries");

            migrationBuilder.DropColumn(
                name: "ReceiverFullName",
                schema: "public",
                table: "OrderDeliveries");

            migrationBuilder.DropColumn(
                name: "ReceiverPhoneNumber",
                schema: "public",
                table: "OrderDeliveries");

            migrationBuilder.AddColumn<Guid>(
                name: "AddressId",
                schema: "public",
                table: "OrderDeliveries",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.CreateIndex(
                name: "IX_OrderDeliveries_AddressId",
                schema: "public",
                table: "OrderDeliveries",
                column: "AddressId");

            migrationBuilder.AddForeignKey(
                name: "FK_OrderDeliveries_UserAddresses_AddressId",
                schema: "public",
                table: "OrderDeliveries",
                column: "AddressId",
                principalSchema: "public",
                principalTable: "UserAddresses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

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

            migrationBuilder.DropIndex(
                name: "IX_OrderDeliveries_AddressId",
                schema: "public",
                table: "OrderDeliveries");

            migrationBuilder.DropColumn(
                name: "AddressId",
                schema: "public",
                table: "OrderDeliveries");

            migrationBuilder.AddColumn<string>(
                name: "Address",
                schema: "public",
                table: "OrderDeliveries",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "PostalCode",
                schema: "public",
                table: "OrderDeliveries",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "ReceiverFullName",
                schema: "public",
                table: "OrderDeliveries",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "ReceiverPhoneNumber",
                schema: "public",
                table: "OrderDeliveries",
                type: "text",
                nullable: false,
                defaultValue: "");
        }
    }
}
