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: "AssetFundamentals", columns: table => new { Isin = table.Column(type: "text", nullable: false), PrimaryTicker = table.Column(type: "text", nullable: false), CompanyName = table.Column(type: "text", nullable: false), BusinessSummary = table.Column(type: "text", nullable: true), Sector = table.Column(type: "text", nullable: true), Industry = table.Column(type: "text", nullable: true), Country = table.Column(type: "text", nullable: true), Employees = table.Column(type: "integer", nullable: true), PercentHeldByInstitutions = table.Column(type: "numeric", nullable: true), PercentHeldByInsiders = table.Column(type: "numeric", nullable: true), ShortRatio = table.Column(type: "numeric", nullable: true), ShortPercentOfFloat = table.Column(type: "numeric", nullable: true), ConsensusRating = table.Column(type: "text", nullable: true), PriceTargetLow = table.Column(type: "numeric", nullable: true), PriceTargetHigh = table.Column(type: "numeric", nullable: true), PriceTargetMedian = table.Column(type: "numeric", nullable: true), PriceTargetMean = table.Column(type: "numeric", nullable: true), ExDividendDate = table.Column(type: "timestamp with time zone", nullable: true), NextEarningsDate = table.Column(type: "timestamp with time zone", nullable: true), LastUpdatedAt = table.Column(type: "timestamp with time zone", nullable: false), LastStaticUpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AssetFundamentals", x => x.Isin); }); migrationBuilder.CreateTable( name: "Settings", columns: table => new { Id = table.Column(type: "uuid", nullable: false), CacheTtlHours = table.Column(type: "integer", nullable: false), EnableYahooFallback = table.Column(type: "boolean", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Settings", x => x.Id); }); migrationBuilder.CreateTable( name: "CompanyExecutives", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Isin = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Title = table.Column(type: "text", nullable: false), Age = table.Column(type: "integer", nullable: true), Compensation = table.Column(type: "numeric", nullable: true) }, constraints: table => { table.PrimaryKey("PK_CompanyExecutives", x => x.Id); table.ForeignKey( name: "FK_CompanyExecutives_AssetFundamentals_Isin", column: x => x.Isin, principalTable: "AssetFundamentals", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "FinancialStatements", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Isin = table.Column(type: "text", nullable: false), PeriodType = table.Column(type: "text", nullable: false), EndDate = table.Column(type: "timestamp with time zone", nullable: false), TotalRevenue = table.Column(type: "numeric", nullable: true), CostOfRevenue = table.Column(type: "numeric", nullable: true), GrossProfit = table.Column(type: "numeric", nullable: true), OperatingExpenses = 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), EpsBasic = table.Column(type: "numeric", nullable: true), EpsDiluted = table.Column(type: "numeric", nullable: true), CashAndCashEquivalents = table.Column(type: "numeric", nullable: true), AccountsReceivable = table.Column(type: "numeric", nullable: true), Inventory = table.Column(type: "numeric", nullable: true), TotalCurrentAssets = table.Column(type: "numeric", nullable: true), TotalNonCurrentAssets = table.Column(type: "numeric", nullable: true), CurrentLiabilities = table.Column(type: "numeric", nullable: true), LongTermDebt = table.Column(type: "numeric", nullable: true), TotalLiabilities = table.Column(type: "numeric", nullable: true), TotalStockholdersEquity = table.Column(type: "numeric", nullable: true), OperatingCashFlow = table.Column(type: "numeric", nullable: true), InvestingCashFlow = table.Column(type: "numeric", nullable: true), CapitalExpenditures = table.Column(type: "numeric", nullable: true), FinancingCashFlow = table.Column(type: "numeric", nullable: true), FreeCashFlow = table.Column(type: "numeric", nullable: true) }, constraints: table => { table.PrimaryKey("PK_FinancialStatements", x => x.Id); table.ForeignKey( name: "FK_FinancialStatements_AssetFundamentals_Isin", column: x => x.Isin, principalTable: "AssetFundamentals", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ForwardEstimates", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Isin = table.Column(type: "text", nullable: false), Period = table.Column(type: "text", nullable: false), ExpectedRevenue = table.Column(type: "numeric", nullable: true), ExpectedEps = table.Column(type: "numeric", nullable: true), ExpectedGrowthRate = table.Column(type: "numeric", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ForwardEstimates", x => x.Id); table.ForeignKey( name: "FK_ForwardEstimates_AssetFundamentals_Isin", column: x => x.Isin, principalTable: "AssetFundamentals", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TickerFundamentals", columns: table => new { Ticker = table.Column(type: "text", nullable: false), Isin = table.Column(type: "text", nullable: false), Exchange = table.Column(type: "text", nullable: true), TradingCurrency = table.Column(type: "text", nullable: true), CurrentPrice = table.Column(type: "numeric", nullable: false), DayChangeAbsolute = table.Column(type: "numeric", nullable: false), DayChangePercent = table.Column(type: "numeric", nullable: false), FiftyTwoWeekHigh = table.Column(type: "numeric", nullable: false), FiftyTwoWeekLow = table.Column(type: "numeric", nullable: false), MarketCapitalization = table.Column(type: "numeric", nullable: false), EnterpriseValue = table.Column(type: "numeric", nullable: false), PeRatioTrailing = table.Column(type: "numeric", nullable: true), PeRatioForward = table.Column(type: "numeric", nullable: true), PegRatio = table.Column(type: "numeric", nullable: true), PbRatio = table.Column(type: "numeric", nullable: true), PsRatio = table.Column(type: "numeric", nullable: true), EvToEbitda = table.Column(type: "numeric", nullable: true), EvToRevenue = table.Column(type: "numeric", nullable: true), GrossMargin = table.Column(type: "numeric", nullable: true), OperatingMargin = table.Column(type: "numeric", nullable: true), NetProfitMargin = table.Column(type: "numeric", nullable: true), ReturnOnEquity = table.Column(type: "numeric", nullable: true), ReturnOnAssets = table.Column(type: "numeric", nullable: true), ReturnOnInvestedCapital = table.Column(type: "numeric", nullable: true), DebtToEquity = table.Column(type: "numeric", nullable: true), CurrentRatio = table.Column(type: "numeric", nullable: true), QuickRatio = table.Column(type: "numeric", nullable: true), InterestCoverage = table.Column(type: "numeric", nullable: true), DividendYield = table.Column(type: "numeric", nullable: true), PayoutRatio = table.Column(type: "numeric", nullable: true), ExDividendDate = table.Column(type: "timestamp with time zone", nullable: true), LastUpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TickerFundamentals", x => x.Ticker); table.ForeignKey( name: "FK_TickerFundamentals_AssetFundamentals_Isin", column: x => x.Isin, principalTable: "AssetFundamentals", principalColumn: "Isin", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AssetFundamentals_PrimaryTicker", table: "AssetFundamentals", column: "PrimaryTicker", unique: true); migrationBuilder.CreateIndex( name: "IX_CompanyExecutives_Isin", table: "CompanyExecutives", column: "Isin"); migrationBuilder.CreateIndex( name: "IX_FinancialStatements_Isin", table: "FinancialStatements", column: "Isin"); migrationBuilder.CreateIndex( name: "IX_FinancialStatements_Isin_PeriodType_EndDate", table: "FinancialStatements", columns: new[] { "Isin", "PeriodType", "EndDate" }, unique: true); migrationBuilder.CreateIndex( name: "IX_ForwardEstimates_Isin", table: "ForwardEstimates", column: "Isin"); migrationBuilder.CreateIndex( name: "IX_ForwardEstimates_Isin_Period", table: "ForwardEstimates", columns: new[] { "Isin", "Period" }, unique: true); migrationBuilder.CreateIndex( name: "IX_TickerFundamentals_Isin", table: "TickerFundamentals", column: "Isin"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "CompanyExecutives"); migrationBuilder.DropTable( name: "FinancialStatements"); migrationBuilder.DropTable( name: "ForwardEstimates"); migrationBuilder.DropTable( name: "Settings"); migrationBuilder.DropTable( name: "TickerFundamentals"); migrationBuilder.DropTable( name: "AssetFundamentals"); } } }