using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace NetinaShop.Repository.Migrations
{
    /// <inheritdoc />
    public partial class AddAuthor : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "AuthorId",
                schema: "public",
                table: "Products",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("8723f1d2-e091-4812-9110-5161c9e23586"));

            migrationBuilder.AddColumn<Guid>(
                name: "AuthorId",
                schema: "public",
                table: "Blogs",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("8723f1d2-e091-4812-9110-5161c9e23586"));

            migrationBuilder.CreateIndex(
                name: "IX_Products_AuthorId",
                schema: "public",
                table: "Products",
                column: "AuthorId");

            migrationBuilder.CreateIndex(
                name: "IX_Blogs_AuthorId",
                schema: "public",
                table: "Blogs",
                column: "AuthorId");

            migrationBuilder.AddForeignKey(
                name: "FK_Blogs_Users_AuthorId",
                schema: "public",
                table: "Blogs",
                column: "AuthorId",
                principalSchema: "public",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_Users_AuthorId",
                schema: "public",
                table: "Products",
                column: "AuthorId",
                principalSchema: "public",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_Products_Users_AuthorId",
                schema: "public",
                table: "Products");

            migrationBuilder.DropIndex(
                name: "IX_Products_AuthorId",
                schema: "public",
                table: "Products");

            migrationBuilder.DropIndex(
                name: "IX_Blogs_AuthorId",
                schema: "public",
                table: "Blogs");

            migrationBuilder.DropColumn(
                name: "AuthorId",
                schema: "public",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "AuthorId",
                schema: "public",
                table: "Blogs");
        }
    }
}
