using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FinlyticSimulation.Migrations { /// public partial class InitialSimulationMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "DynamicSettings", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Key = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), ValueJson = table.Column(type: "text", nullable: false), ServiceIdentifier = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), LastUpdatedUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DynamicSettings", x => x.Id); }); migrationBuilder.CreateTable( name: "simulation_runs", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Isin = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), Symbol = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), StrategyKey = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Timeframe = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), StartDateUtc = table.Column(type: "timestamp with time zone", nullable: false), EndDateUtc = table.Column(type: "timestamp with time zone", nullable: false), StartingCapital = table.Column(type: "numeric(18,4)", nullable: false), TotalTrades = table.Column(type: "integer", nullable: false), WinningTrades = table.Column(type: "integer", nullable: false), LosingTrades = table.Column(type: "integer", nullable: false), WinRatePercent = table.Column(type: "numeric(6,2)", nullable: false), ProfitFactor = table.Column(type: "numeric(8,4)", nullable: false), MaxDrawdownPercent = table.Column(type: "numeric(6,2)", nullable: false), TotalReturnPercent = table.Column(type: "numeric(8,2)", nullable: false), ExpectancyEur = table.Column(type: "numeric(18,4)", nullable: false), SharpeRatio = table.Column(type: "numeric(8,4)", nullable: false), ReportJson = table.Column(type: "jsonb", nullable: false), CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_simulation_runs", x => x.Id); }); migrationBuilder.CreateTable( name: "simulation_strategy_matrix", columns: table => new { Isin = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), StrategyKey = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Timeframe = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), SampleTradesCount = table.Column(type: "integer", nullable: false), WinRatePercent = table.Column(type: "numeric(6,2)", nullable: false), ProfitFactor = table.Column(type: "numeric(8,4)", nullable: false), MaxDrawdownPercent = table.Column(type: "numeric(6,2)", nullable: false), ReliabilityScore = table.Column(type: "numeric(5,2)", nullable: false), IsApproved = table.Column(type: "boolean", nullable: false), RecommendedAction = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), LastBacktestRunId = table.Column(type: "uuid", nullable: true), UpdatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_simulation_strategy_matrix", x => new { x.Isin, x.StrategyKey, x.Timeframe }); }); migrationBuilder.CreateIndex( name: "IX_DynamicSettings_Key", table: "DynamicSettings", column: "Key", unique: true); migrationBuilder.CreateIndex( name: "IX_simulation_runs_CreatedAtUtc", table: "simulation_runs", column: "CreatedAtUtc"); migrationBuilder.CreateIndex( name: "IX_simulation_runs_Isin_StrategyKey_Timeframe", table: "simulation_runs", columns: new[] { "Isin", "StrategyKey", "Timeframe" }); migrationBuilder.CreateIndex( name: "IX_simulation_strategy_matrix_Isin_IsApproved", table: "simulation_strategy_matrix", columns: new[] { "Isin", "IsApproved" }); migrationBuilder.CreateIndex( name: "IX_simulation_strategy_matrix_ReliabilityScore", table: "simulation_strategy_matrix", column: "ReliabilityScore"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DynamicSettings"); migrationBuilder.DropTable( name: "simulation_runs"); migrationBuilder.DropTable( name: "simulation_strategy_matrix"); } } }