using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace FoodsharingSiegen.Server.Migrations
{
    /// <inheritdoc />
    public partial class AddImageVerification : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "VerificationToken",
                table: "Prospects",
                type: "TEXT",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "ProspectImages",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    ProspectId = table.Column<Guid>(type: "TEXT", nullable: false),
                    ImageData = table.Column<byte[]>(type: "BLOB", nullable: false),
                    ContentType = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
                    Created = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProspectImages", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProspectImages_Prospects_ProspectId",
                        column: x => x.ProspectId,
                        principalTable: "Prospects",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ProspectImages_ProspectId",
                table: "ProspectImages",
                column: "ProspectId");
        }

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

            migrationBuilder.DropColumn(
                name: "VerificationToken",
                table: "Prospects");
        }
    }
}
