using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace api.Migrations { /// public partial class init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Stocks", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Symbol = table.Column(type: "nvarchar(max)", nullable: false), CompanyName = table.Column(type: "nvarchar(max)", nullable: false), Purchase = table.Column(type: "decimal(18,2)", nullable: false), LastDiv = table.Column(type: "decimal(18,2)", nullable: false), Industry = table.Column(type: "nvarchar(max)", nullable: false), MarketCap = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Stocks", x => x.Id); }); migrationBuilder.CreateTable( name: "Comments", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(max)", nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: false), CreatedOn = table.Column(type: "datetime2", nullable: false), StockId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Comments", x => x.Id); table.ForeignKey( name: "FK_Comments_Stocks_StockId", column: x => x.StockId, principalTable: "Stocks", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Comments_StockId", table: "Comments", column: "StockId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Comments"); migrationBuilder.DropTable( name: "Stocks"); } } }