using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace GerbilManagerWebAPI.Migrations
{
    /// <inheritdoc />
    public partial class AddVerifiedGerbilAndManualFlag : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<bool>(
                name: "IsManual",
                table: "Litters",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsManual",
                table: "Gerbils",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsManual",
                table: "Contacts",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.CreateTable(
                name: "GerbilOverrides",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    GerbilId = table.Column<Guid>(type: "uuid", nullable: false),
                    EntityName = table.Column<string>(type: "text", nullable: true),
                    IsVerified = table.Column<bool>(type: "boolean", nullable: false),
                    OverrideJson = table.Column<string>(type: "text", nullable: false),
                    SnapshotJson = table.Column<string>(type: "text", nullable: true),
                    LastImportSnapshotJson = table.Column<string>(type: "text", nullable: true),
                    LastImportDiffJson = table.Column<string>(type: "text", nullable: true),
                    Note = table.Column<string>(type: "text", nullable: true),
                    VerifiedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
                    UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GerbilOverrides", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_GerbilOverrides_GerbilId",
                table: "GerbilOverrides",
                column: "GerbilId",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "GerbilOverrides");

            migrationBuilder.DropColumn(
                name: "IsManual",
                table: "Litters");

            migrationBuilder.DropColumn(
                name: "IsManual",
                table: "Gerbils");

            migrationBuilder.DropColumn(
                name: "IsManual",
                table: "Contacts");
        }
    }
}
