using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace FinlyticTechnicals.Migrations { /// public partial class Init : 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: "fta_candles", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Isin = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), Symbol = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), Timeframe = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), TimestampUtc = table.Column(type: "timestamp with time zone", nullable: false), Open = table.Column(type: "numeric(18,4)", nullable: false), High = table.Column(type: "numeric(18,4)", nullable: false), Low = table.Column(type: "numeric(18,4)", nullable: false), Close = table.Column(type: "numeric(18,4)", nullable: false), Volume = table.Column(type: "bigint", nullable: false), Bid = table.Column(type: "numeric(18,4)", nullable: true), Ask = table.Column(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(type: "uuid", nullable: false), Isin = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), Timeframe = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), PatternType = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Category = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), Bias = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), KeyPriceLevel = table.Column(type: "numeric(18,4)", nullable: false), UpperBoundary = table.Column(type: "numeric(18,4)", nullable: false), LowerBoundary = table.Column(type: "numeric(18,4)", nullable: false), InvalidationLevel = table.Column(type: "numeric(18,4)", nullable: false), QualityScore = table.Column(type: "numeric(6,2)", nullable: false), Description = table.Column(type: "text", nullable: false), ExtraData = table.Column(type: "jsonb", nullable: true), DetectedAtUtc = table.Column(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(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), Timeframe = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), StrategyKey = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), StrategyName = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Direction = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), QualityScore = table.Column(type: "numeric(6,2)", nullable: false), CurrentPrice = table.Column(type: "numeric(18,4)", nullable: false), EntryPrice = table.Column(type: "numeric(18,4)", nullable: false), InvalidationPrice = table.Column(type: "numeric(18,4)", nullable: false), CurrentAtr = table.Column(type: "numeric(18,4)", nullable: false), EstimatedRiskRewardRatio = table.Column(type: "numeric(8,2)", nullable: false), ExitPlan = table.Column(type: "jsonb", nullable: false), TechnicalRationale = table.Column(type: "text", nullable: false), TriggeringPatterns = table.Column(type: "jsonb", nullable: false), IndicatorSnapshot = table.Column(type: "jsonb", nullable: false), IsTopPick = table.Column(type: "boolean", nullable: false), Rating = table.Column(type: "character varying(5)", maxLength: 5, nullable: false), IsActive = table.Column(type: "boolean", nullable: false), CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), ExpiresAtUtc = table.Column(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"); } /// 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"); } } }