using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace NetinaShop.Repository.Migrations
{
    /// <inheritdoc />
    public partial class EditBlogCategoryAddIsMain : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("Npgsql:PostgresExtension:fuzzystrmatch", ",,")
                .Annotation("Npgsql:PostgresExtension:pg_trgm", ",,");

            migrationBuilder.AddColumn<bool>(
                name: "IsMain",
                schema: "public",
                table: "BlogCategories",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<Guid>(
                name: "ParentId",
                schema: "public",
                table: "BlogCategories",
                type: "uuid",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_BlogCategories_ParentId",
                schema: "public",
                table: "BlogCategories",
                column: "ParentId");

            migrationBuilder.AddForeignKey(
                name: "FK_BlogCategories_BlogCategories_ParentId",
                schema: "public",
                table: "BlogCategories",
                column: "ParentId",
                principalSchema: "public",
                principalTable: "BlogCategories",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropIndex(
                name: "IX_BlogCategories_ParentId",
                schema: "public",
                table: "BlogCategories");

            migrationBuilder.DropColumn(
                name: "IsMain",
                schema: "public",
                table: "BlogCategories");

            migrationBuilder.DropColumn(
                name: "ParentId",
                schema: "public",
                table: "BlogCategories");

            migrationBuilder.AlterDatabase()
                .OldAnnotation("Npgsql:PostgresExtension:fuzzystrmatch", ",,")
                .OldAnnotation("Npgsql:PostgresExtension:pg_trgm", ",,");
        }
    }
}
