using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FinlyticBot.Migrations { /// public partial class InitialBotMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "bot_portfolio_snapshots", columns: table => new { Id = table.Column(type: "uuid", nullable: false), SnapshotDateUtc = table.Column(type: "timestamp with time zone", nullable: false), TotalEquityEur = table.Column(type: "numeric(18,4)", nullable: false), CashEur = table.Column(type: "numeric(18,4)", nullable: false), OpenPositionsCount = table.Column(type: "integer", nullable: false), DailyRealizedPnlEur = table.Column(type: "numeric(18,4)", nullable: false), TotalUnrealizedPnlEur = table.Column(type: "numeric(18,4)", nullable: false), WinRatePercent = table.Column(type: "numeric(6,2)", nullable: true), CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_bot_portfolio_snapshots", x => x.Id); }); migrationBuilder.CreateTable( name: "bot_positions", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ProposalId = 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), Venue = table.Column(type: "integer", nullable: false), AlpacaOrderId = table.Column(type: "character varying(60)", maxLength: 60, nullable: true), ClientOrderId = table.Column(type: "character varying(60)", maxLength: 60, nullable: true), Direction = table.Column(type: "integer", nullable: false), Quantity = table.Column(type: "numeric(18,4)", nullable: false), EntryPrice = table.Column(type: "numeric(18,4)", nullable: false), AverageBuyIn = table.Column(type: "numeric(18,4)", nullable: false), InitialStopLoss = table.Column(type: "numeric(18,4)", nullable: false), CurrentStopLoss = table.Column(type: "numeric(18,4)", nullable: false), CurrentPrice = table.Column(type: "numeric(18,4)", nullable: false), TakeProfit1 = table.Column(type: "numeric(18,4)", nullable: false), TakeProfit2 = table.Column(type: "numeric(18,4)", nullable: false), RealizedPnlEur = table.Column(type: "numeric(18,4)", nullable: false), TotalFeesEur = table.Column(type: "numeric(18,4)", nullable: false), Status = table.Column(type: "integer", nullable: false), ExitPlan = table.Column(type: "jsonb", nullable: false), OpenedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), ClosedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), LastSyncAtUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_bot_positions", x => x.Id); }); 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.CreateIndex( name: "IX_bot_portfolio_snapshots_SnapshotDateUtc", table: "bot_portfolio_snapshots", column: "SnapshotDateUtc"); migrationBuilder.CreateIndex( name: "IX_bot_positions_OpenedAtUtc", table: "bot_positions", column: "OpenedAtUtc"); migrationBuilder.CreateIndex( name: "IX_bot_positions_ProposalId", table: "bot_positions", column: "ProposalId"); migrationBuilder.CreateIndex( name: "IX_bot_positions_Status_Venue", table: "bot_positions", columns: new[] { "Status", "Venue" }); migrationBuilder.CreateIndex( name: "IX_DynamicSettings_Key", table: "DynamicSettings", column: "Key", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "bot_portfolio_snapshots"); migrationBuilder.DropTable( name: "bot_positions"); migrationBuilder.DropTable( name: "DynamicSettings"); } } }