using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FinlyticFundamentals.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AssetData", columns: table => new { Isin = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), PrimaryTicker = table.Column(type: "text", nullable: false, defaultValue: ""), PrimaryTickerExchange = table.Column(type: "text", nullable: false, defaultValue: "") }, constraints: table => { table.PrimaryKey("PK_AssetData", x => x.Isin); }); 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: "AssetEvents", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Ticker = table.Column(type: "text", nullable: false, defaultValue: ""), TickerExchange = table.Column(type: "text", nullable: false, defaultValue: ""), Type = table.Column(type: "text", nullable: false), Date = table.Column(type: "timestamp with time zone", nullable: false), AssetDataIsin = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AssetEvents", x => x.Id); table.ForeignKey( name: "FK_AssetEvents_AssetData_AssetDataIsin", column: x => x.AssetDataIsin, principalTable: "AssetData", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "FundamentalData", columns: table => new { Isin = table.Column(type: "text", nullable: false), Ticker = table.Column(type: "text", nullable: false, defaultValue: ""), TickerExchange = table.Column(type: "text", nullable: false, defaultValue: ""), MarketCap = table.Column(type: "numeric", nullable: true), EnterpriseValue = table.Column(type: "numeric", nullable: true), TrailingPe = table.Column(type: "numeric", nullable: true), ForwardPe = table.Column(type: "numeric", nullable: true), PegRatio = table.Column(type: "numeric", nullable: true), PriceToSales = table.Column(type: "numeric", nullable: true), PriceToBook = table.Column(type: "numeric", nullable: true), EvToEbitda = table.Column(type: "numeric", nullable: true), TotalRevenue = table.Column(type: "numeric", nullable: true), RevenueGrowthYoY = table.Column(type: "numeric", nullable: true), GrossProfit = table.Column(type: "numeric", nullable: true), OperatingIncome = table.Column(type: "numeric", nullable: true), Ebitda = table.Column(type: "numeric", nullable: true), NetIncome = table.Column(type: "numeric", nullable: true), DilutedEps = table.Column(type: "numeric", nullable: true), TotalCash = table.Column(type: "numeric", nullable: true), TotalDebt = table.Column(type: "numeric", nullable: true), DebtToEquity = table.Column(type: "numeric", nullable: true), CurrentRatio = table.Column(type: "numeric", nullable: true), OperatingCashFlow = table.Column(type: "numeric", nullable: true), FreeCashFlow = table.Column(type: "numeric", nullable: true), ReturnOnEquity = table.Column(type: "numeric", nullable: true), ReturnOnAssets = table.Column(type: "numeric", nullable: true), ForwardDividendYield = table.Column(type: "numeric", nullable: true), PayoutRatio = table.Column(type: "numeric", nullable: true), LastUpdatedUtc = table.Column(type: "timestamp with time zone", nullable: false), AssetDataIsin = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_FundamentalData", x => x.Isin); table.ForeignKey( name: "FK_FundamentalData_AssetData_AssetDataIsin", column: x => x.AssetDataIsin, principalTable: "AssetData", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "KeyExecutives", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Title = table.Column(type: "text", nullable: false), Payment = table.Column(type: "text", nullable: false), AssetDataIsin = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_KeyExecutives", x => x.Id); table.ForeignKey( name: "FK_KeyExecutives_AssetData_AssetDataIsin", column: x => x.AssetDataIsin, principalTable: "AssetData", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Tickers", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Ticker = table.Column(type: "text", nullable: false), Exchange = table.Column(type: "text", nullable: false), AssetDataIsin = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tickers", x => x.Id); table.ForeignKey( name: "FK_Tickers_AssetData_AssetDataIsin", column: x => x.AssetDataIsin, principalTable: "AssetData", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AssetEvents_AssetDataIsin", table: "AssetEvents", column: "AssetDataIsin"); migrationBuilder.CreateIndex( name: "IX_DynamicSettings_Key", table: "DynamicSettings", column: "Key"); migrationBuilder.CreateIndex( name: "IX_FundamentalData_AssetDataIsin", table: "FundamentalData", column: "AssetDataIsin"); migrationBuilder.CreateIndex( name: "IX_KeyExecutives_AssetDataIsin", table: "KeyExecutives", column: "AssetDataIsin"); migrationBuilder.CreateIndex( name: "IX_Tickers_AssetDataIsin", table: "Tickers", column: "AssetDataIsin"); migrationBuilder.CreateIndex( name: "IX_Tickers_Ticker", table: "Tickers", column: "Ticker"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AssetEvents"); migrationBuilder.DropTable( name: "DynamicSettings"); migrationBuilder.DropTable( name: "FundamentalData"); migrationBuilder.DropTable( name: "KeyExecutives"); migrationBuilder.DropTable( name: "Tickers"); migrationBuilder.DropTable( name: "AssetData"); } } }