using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Predictalytics.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class AddFingerprintSnapshots : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TraderFingerprintSnapshots",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    TraderId = table.Column<int>(type: "int", nullable: false),
                    CapturedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CopytradingScore = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    CategoryConcentration = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    ConvictionEdgePct = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
                    P50PositionSize = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    P90PositionSize = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    MedianHoldDurationHours = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    TradesPerWeek = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    CategoryMixJson = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TraitSetJson = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TraderFingerprintSnapshots", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TraderFingerprintSnapshots_Traders_TraderId",
                        column: x => x.TraderId,
                        principalTable: "Traders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_TraderFingerprintSnapshots_TraderId_CapturedAt",
                table: "TraderFingerprintSnapshots",
                columns: new[] { "TraderId", "CapturedAt" });
        }

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