using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinlyticBot.Migrations
{
///
public partial class InitBotDatabase : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BotAuditLogs",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
TradeId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
Symbol = table.Column(type: "character varying(30)", maxLength: 30, nullable: false),
Action = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
IsAccepted = table.Column(type: "boolean", nullable: false),
Reason = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
CalculatedSize = table.Column(type: "numeric(18,4)", nullable: true),
AccountEquity = table.Column(type: "numeric(18,4)", nullable: true),
Timestamp = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BotAuditLogs", 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.CreateTable(
name: "ExecutedPaperTrades",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
TradeId = table.Column(type: "character varying(100)", maxLength: 100, 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(200)", maxLength: 200, nullable: false),
AlpacaOrderId = table.Column(type: "uuid", nullable: true),
Side = table.Column(type: "character varying(20)", maxLength: 20, nullable: false),
Quantity = table.Column(type: "numeric(18,4)", nullable: false),
SignalEntryPrice = table.Column(type: "numeric(18,4)", nullable: false),
ActualFillPrice = table.Column(type: "numeric(18,4)", nullable: true),
StopLossPrice = table.Column(type: "numeric(18,4)", nullable: false),
TakeProfitPrice1 = table.Column(type: "numeric(18,4)", nullable: false),
TakeProfitPrice2 = table.Column(type: "numeric(18,4)", nullable: true),
CalculatedCrv = table.Column(type: "numeric(18,4)", nullable: false),
WinRate = table.Column(type: "double precision", nullable: false),
SlippagePercent = table.Column(type: "numeric(18,4)", nullable: true),
RealizedPnl = table.Column(type: "numeric(18,4)", nullable: false),
RealizedPnlPercent = table.Column(type: "numeric(18,4)", nullable: true),
Status = table.Column(type: "character varying(30)", maxLength: 30, nullable: false),
RejectReason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true),
PlacedAt = table.Column(type: "timestamp with time zone", nullable: false),
FilledAt = table.Column(type: "timestamp with time zone", nullable: true),
ClosedAt = table.Column(type: "timestamp with time zone", nullable: true),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExecutedPaperTrades", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_BotAuditLogs_Action",
table: "BotAuditLogs",
column: "Action");
migrationBuilder.CreateIndex(
name: "IX_BotAuditLogs_Symbol",
table: "BotAuditLogs",
column: "Symbol");
migrationBuilder.CreateIndex(
name: "IX_BotAuditLogs_Timestamp",
table: "BotAuditLogs",
column: "Timestamp");
migrationBuilder.CreateIndex(
name: "IX_BotAuditLogs_TradeId",
table: "BotAuditLogs",
column: "TradeId");
migrationBuilder.CreateIndex(
name: "IX_DynamicSettings_Key",
table: "DynamicSettings",
column: "Key",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ExecutedPaperTrades_AlpacaOrderId",
table: "ExecutedPaperTrades",
column: "AlpacaOrderId");
migrationBuilder.CreateIndex(
name: "IX_ExecutedPaperTrades_Isin",
table: "ExecutedPaperTrades",
column: "Isin");
migrationBuilder.CreateIndex(
name: "IX_ExecutedPaperTrades_PlacedAt",
table: "ExecutedPaperTrades",
column: "PlacedAt");
migrationBuilder.CreateIndex(
name: "IX_ExecutedPaperTrades_Status",
table: "ExecutedPaperTrades",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_ExecutedPaperTrades_Symbol",
table: "ExecutedPaperTrades",
column: "Symbol");
migrationBuilder.CreateIndex(
name: "IX_ExecutedPaperTrades_TradeId",
table: "ExecutedPaperTrades",
column: "TradeId",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BotAuditLogs");
migrationBuilder.DropTable(
name: "DynamicSettings");
migrationBuilder.DropTable(
name: "ExecutedPaperTrades");
}
}
}