179 lines
9.4 KiB
C#
179 lines
9.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace FinlyticTechnicals.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "DynamicSettings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Key = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
|
|
ValueJson = table.Column<string>(type: "text", nullable: false),
|
|
ServiceIdentifier = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
LastUpdatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DynamicSettings", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "fta_candles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Isin = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
Symbol = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
Timeframe = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
TimestampUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Open = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
High = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
Low = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
Close = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
Volume = table.Column<long>(type: "bigint", nullable: false),
|
|
Bid = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
|
|
Ask = table.Column<decimal>(type: "numeric(18,4)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_fta_candles", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "fta_detected_patterns",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Isin = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
Timeframe = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
PatternType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
Category = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
Bias = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
KeyPriceLevel = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
UpperBoundary = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
LowerBoundary = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
InvalidationLevel = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
QualityScore = table.Column<decimal>(type: "numeric(6,2)", nullable: false),
|
|
Description = table.Column<string>(type: "text", nullable: false),
|
|
ExtraData = table.Column<string>(type: "jsonb", nullable: true),
|
|
DetectedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_fta_detected_patterns", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "fta_technical_setups",
|
|
columns: table => new
|
|
{
|
|
SetupId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Isin = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
Symbol = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
Timeframe = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
StrategyKey = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
StrategyName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
Direction = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
QualityScore = table.Column<decimal>(type: "numeric(6,2)", nullable: false),
|
|
CurrentPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
EntryPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
InvalidationPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
CurrentAtr = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
EstimatedRiskRewardRatio = table.Column<decimal>(type: "numeric(8,2)", nullable: false),
|
|
ExitPlan = table.Column<string>(type: "jsonb", nullable: false),
|
|
TechnicalRationale = table.Column<string>(type: "text", nullable: false),
|
|
TriggeringPatterns = table.Column<string>(type: "jsonb", nullable: false),
|
|
IndicatorSnapshot = table.Column<string>(type: "jsonb", nullable: false),
|
|
IsTopPick = table.Column<bool>(type: "boolean", nullable: false),
|
|
Rating = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: false),
|
|
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
CreatedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
ExpiresAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_fta_technical_setups", x => x.SetupId);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DynamicSettings_Key",
|
|
table: "DynamicSettings",
|
|
column: "Key",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_candles_Isin_Timeframe_TimestampUtc",
|
|
table: "fta_candles",
|
|
columns: new[] { "Isin", "Timeframe", "TimestampUtc" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_candles_TimestampUtc",
|
|
table: "fta_candles",
|
|
column: "TimestampUtc");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_detected_patterns_Isin_DetectedAtUtc",
|
|
table: "fta_detected_patterns",
|
|
columns: new[] { "Isin", "DetectedAtUtc" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_detected_patterns_PatternType",
|
|
table: "fta_detected_patterns",
|
|
column: "PatternType");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_detected_patterns_QualityScore",
|
|
table: "fta_detected_patterns",
|
|
column: "QualityScore");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_technical_setups_CreatedAtUtc",
|
|
table: "fta_technical_setups",
|
|
column: "CreatedAtUtc");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_technical_setups_Isin_IsActive_ExpiresAtUtc",
|
|
table: "fta_technical_setups",
|
|
columns: new[] { "Isin", "IsActive", "ExpiresAtUtc" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_technical_setups_IsTopPick",
|
|
table: "fta_technical_setups",
|
|
column: "IsTopPick");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_fta_technical_setups_QualityScore",
|
|
table: "fta_technical_setups",
|
|
column: "QualityScore");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DynamicSettings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "fta_candles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "fta_detected_patterns");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "fta_technical_setups");
|
|
}
|
|
}
|
|
}
|