using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FinlyticTrades.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Settings", columns: table => new { Id = table.Column(type: "uuid", nullable: false), AtrStopLossMultiplier = table.Column(type: "double precision", nullable: false), RiskPerTradePercentage = table.Column(type: "double precision", nullable: false), MaxOpenPositions = table.Column(type: "integer", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Settings", x => x.Id); }); migrationBuilder.CreateTable( name: "trades", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TradeId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), AnalysisId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), EventId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Sector = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Symbol = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), Isin = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), CompanyName = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), Status = table.Column(type: "integer", nullable: false), EntryPrice = table.Column(type: "numeric(18,4)", nullable: false), StopLoss = table.Column(type: "numeric(18,4)", nullable: false), TakeProfit = table.Column(type: "numeric(18,4)", nullable: false), SignalType = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), RiskTolerance = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), Timeframe = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), InstrumentType = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), WinRate = table.Column(type: "double precision", nullable: false), VixRegime = table.Column(type: "integer", nullable: false), VixValue = table.Column(type: "numeric(18,4)", nullable: false), TtlMinutes = table.Column(type: "integer", nullable: false), Reasoning = table.Column(type: "text", nullable: false), UserExitPrice = table.Column(type: "numeric(18,4)", nullable: true), UserExitTimestamp = table.Column(type: "timestamp with time zone", nullable: true), CloseReason = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), PnlAbsolute = table.Column(type: "numeric(18,4)", nullable: true), PnlPercent = table.Column(type: "numeric(18,4)", nullable: true), IsWin = table.Column(type: "boolean", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), ClosedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_trades", x => x.Id); }); migrationBuilder.CreateTable( name: "trade_hourly_updates", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TradeId = table.Column(type: "uuid", nullable: false), Recommendation = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), CurrentPrice = table.Column(type: "numeric(18,4)", nullable: false), SuggestedStopLoss = table.Column(type: "numeric(18,4)", nullable: true), SuggestedTakeProfit = table.Column(type: "numeric(18,4)", nullable: true), VixValue = table.Column(type: "numeric(18,4)", nullable: false), Reasoning = table.Column(type: "text", nullable: false), Timestamp = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_trade_hourly_updates", x => x.Id); table.ForeignKey( name: "FK_trade_hourly_updates_trades_TradeId", column: x => x.TradeId, principalTable: "trades", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_trade_hourly_updates_Timestamp", table: "trade_hourly_updates", column: "Timestamp"); migrationBuilder.CreateIndex( name: "IX_trade_hourly_updates_TradeId", table: "trade_hourly_updates", column: "TradeId"); migrationBuilder.CreateIndex( name: "IX_trades_AnalysisId", table: "trades", column: "AnalysisId"); migrationBuilder.CreateIndex( name: "IX_trades_CreatedAt", table: "trades", column: "CreatedAt"); migrationBuilder.CreateIndex( name: "IX_trades_EventId", table: "trades", column: "EventId"); migrationBuilder.CreateIndex( name: "IX_trades_Isin", table: "trades", column: "Isin"); migrationBuilder.CreateIndex( name: "IX_trades_Sector", table: "trades", column: "Sector"); migrationBuilder.CreateIndex( name: "IX_trades_Status", table: "trades", column: "Status"); migrationBuilder.CreateIndex( name: "IX_trades_TradeId", table: "trades", column: "TradeId", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Settings"); migrationBuilder.DropTable( name: "trade_hourly_updates"); migrationBuilder.DropTable( name: "trades"); } } }