using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class u04 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<DateTime>(
                name: "BirthDate",
                schema: "CMS",
                table: "Users",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "EmailNotifications",
                schema: "CMS",
                table: "Users",
                type: "bit",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "PushNotifications",
                schema: "CMS",
                table: "Users",
                type: "bit",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "SmsNotifications",
                schema: "CMS",
                table: "Users",
                type: "bit",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<long>(
                name: "UserAddressId",
                schema: "CMS",
                table: "UserOrders",
                type: "bigint",
                nullable: false,
                defaultValue: 0L);

            migrationBuilder.CreateIndex(
                name: "IX_UserOrders_UserAddressId",
                schema: "CMS",
                table: "UserOrders",
                column: "UserAddressId");

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

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

            migrationBuilder.DropIndex(
                name: "IX_UserOrders_UserAddressId",
                schema: "CMS",
                table: "UserOrders");

            migrationBuilder.DropColumn(
                name: "BirthDate",
                schema: "CMS",
                table: "Users");

            migrationBuilder.DropColumn(
                name: "EmailNotifications",
                schema: "CMS",
                table: "Users");

            migrationBuilder.DropColumn(
                name: "PushNotifications",
                schema: "CMS",
                table: "Users");

            migrationBuilder.DropColumn(
                name: "SmsNotifications",
                schema: "CMS",
                table: "Users");

            migrationBuilder.DropColumn(
                name: "UserAddressId",
                schema: "CMS",
                table: "UserOrders");
        }
    }
}
