using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PolyTrader.Modules.CopyTrading.Persistence.Ef.Migrations
{
    /// <inheritdoc />
    public partial class AddCopytradingBehaviorSettings : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<bool>(
                name: "AutoPauseEnabled",
                table: "mod_copytrading_traders",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: true);

            migrationBuilder.AddColumn<bool>(
                name: "MakerEntry",
                table: "mod_copytrading_traders",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<decimal>(
                name: "MaxSpreadPct",
                table: "mod_copytrading_account_settings",
                type: "decimal(18,6)",
                precision: 18,
                scale: 6,
                nullable: false,
                defaultValue: 5m);

            migrationBuilder.AddColumn<decimal>(
                name: "MinSellRatioPct",
                table: "mod_copytrading_account_settings",
                type: "decimal(18,6)",
                precision: 18,
                scale: 6,
                nullable: false,
                defaultValue: 10m);

            migrationBuilder.AddColumn<decimal>(
                name: "SellFloorPct",
                table: "mod_copytrading_account_settings",
                type: "decimal(18,6)",
                precision: 18,
                scale: 6,
                nullable: false,
                defaultValue: 15m);

            // Entscheidung Richard: ProfitTarget zunächst überall auf 9999 (praktisch deaktiviert),
            // bis die Take-Profit-Logik (Phase 0.3) scharf geschaltet wird.
            migrationBuilder.Sql("UPDATE mod_copytrading_account_settings SET ProfitTarget = 9999;");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "AutoPauseEnabled",
                table: "mod_copytrading_traders");

            migrationBuilder.DropColumn(
                name: "MakerEntry",
                table: "mod_copytrading_traders");

            migrationBuilder.DropColumn(
                name: "MaxSpreadPct",
                table: "mod_copytrading_account_settings");

            migrationBuilder.DropColumn(
                name: "MinSellRatioPct",
                table: "mod_copytrading_account_settings");

            migrationBuilder.DropColumn(
                name: "SellFloorPct",
                table: "mod_copytrading_account_settings");
        }
    }
}
