refactor(assets): update asset entity mappings, database migrations, and MQTT RPC handlers
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FinlyticAssets.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Derivatives",
|
||||
columns: table => new
|
||||
{
|
||||
Isin = table.Column<string>(type: "character varying(12)", maxLength: 12, nullable: false),
|
||||
UnderlyingIsin = table.Column<string>(type: "character varying(12)", maxLength: 12, nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
OptionType = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductCategoryName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
NextGenProductCategoryName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
Strike = table.Column<decimal>(type: "numeric(18,6)", nullable: false),
|
||||
Barrier = table.Column<decimal>(type: "numeric(18,6)", nullable: false),
|
||||
Leverage = table.Column<decimal>(type: "numeric(10,4)", nullable: false),
|
||||
Size = table.Column<decimal>(type: "numeric", nullable: true),
|
||||
Factor = table.Column<decimal>(type: "numeric", nullable: true),
|
||||
Delta = table.Column<decimal>(type: "numeric", nullable: true),
|
||||
Currency = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
||||
Expiry = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
Issuer = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
|
||||
IssuerDisplayName = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DerivativeProductCategories = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Derivatives", x => x.Isin);
|
||||
});
|
||||
|
||||
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: "TradeRepublicAssets",
|
||||
columns: table => new
|
||||
{
|
||||
Isin = table.Column<string>(type: "text", nullable: false),
|
||||
InstrumentCategory = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Type = table.Column<string>(type: "text", nullable: false),
|
||||
HasCfd = table.Column<bool>(type: "boolean", nullable: false),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
AssetType = table.Column<string>(type: "character varying(13)", maxLength: 13, nullable: false),
|
||||
DerivativeProductCategories = table.Column<string>(type: "text", nullable: true),
|
||||
EtfDescription = table.Column<string>(type: "text", nullable: true),
|
||||
MappedEtfIndexName = table.Column<string>(type: "text", nullable: true),
|
||||
Subtitle = table.Column<string>(type: "text", nullable: true),
|
||||
SearchSubtitle = table.Column<string>(type: "text", nullable: true),
|
||||
StockEntity_DerivativeProductCategories = table.Column<string>(type: "text", nullable: true),
|
||||
SyntheticEntity_DerivativeProductCategories = table.Column<string>(type: "text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_TradeRepublicAssets", x => new { x.Isin, x.InstrumentCategory });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "TradeRepublicTags",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Type = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_TradeRepublicTags", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AssetEntityTagEntity",
|
||||
columns: table => new
|
||||
{
|
||||
TagsId = table.Column<string>(type: "text", nullable: false),
|
||||
AssetsIsin = table.Column<string>(type: "text", nullable: false),
|
||||
AssetsInstrumentCategory = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AssetEntityTagEntity", x => new { x.TagsId, x.AssetsIsin, x.AssetsInstrumentCategory });
|
||||
table.ForeignKey(
|
||||
name: "FK_AssetEntityTagEntity_TradeRepublicAssets_AssetsIsin_AssetsI~",
|
||||
columns: x => new { x.AssetsIsin, x.AssetsInstrumentCategory },
|
||||
principalTable: "TradeRepublicAssets",
|
||||
principalColumns: new[] { "Isin", "InstrumentCategory" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_AssetEntityTagEntity_TradeRepublicTags_TagsId",
|
||||
column: x => x.TagsId,
|
||||
principalTable: "TradeRepublicTags",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AssetEntityTagEntity_AssetsIsin_AssetsInstrumentCategory",
|
||||
table: "AssetEntityTagEntity",
|
||||
columns: new[] { "AssetsIsin", "AssetsInstrumentCategory" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Derivatives_LastUpdatedAt",
|
||||
table: "Derivatives",
|
||||
column: "LastUpdatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Derivatives_Leverage",
|
||||
table: "Derivatives",
|
||||
column: "Leverage");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Derivatives_OptionType",
|
||||
table: "Derivatives",
|
||||
column: "OptionType");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Derivatives_UnderlyingIsin",
|
||||
table: "Derivatives",
|
||||
column: "UnderlyingIsin");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DynamicSettings_Key",
|
||||
table: "DynamicSettings",
|
||||
column: "Key",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TradeRepublicAssets_LastUpdatedAt",
|
||||
table: "TradeRepublicAssets",
|
||||
column: "LastUpdatedAt");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AssetEntityTagEntity");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Derivatives");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "DynamicSettings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TradeRepublicAssets");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TradeRepublicTags");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user