using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MemberCenter.Infrastructure.Persistence.Migrations
{
    public partial class AddEmailBlacklist : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<bool>(
                name: "IsBlacklisted",
                table: "users",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<DateTimeOffset>(
                name: "BlacklistedAt",
                table: "users",
                type: "timestamp with time zone",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "BlacklistedBy",
                table: "users",
                type: "text",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "email_blacklist",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    Email = table.Column<string>(type: "text", nullable: false),
                    Reason = table.Column<string>(type: "text", nullable: false),
                    BlacklistedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
                    BlacklistedBy = table.Column<string>(type: "text", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_email_blacklist", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_email_blacklist_Email",
                table: "email_blacklist",
                column: "Email",
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "email_blacklist");

            migrationBuilder.DropColumn(
                name: "IsBlacklisted",
                table: "users");

            migrationBuilder.DropColumn(
                name: "BlacklistedAt",
                table: "users");

            migrationBuilder.DropColumn(
                name: "BlacklistedBy",
                table: "users");
        }
    }
}
