70 lines
2.7 KiB
C#
70 lines
2.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Stocks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Symbol = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CompanyName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Purchase = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
LastDiv = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
Industry = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
MarketCap = table.Column<long>(type: "bigint", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Stocks", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Comments",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CreatedOn = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
StockId = table.Column<int>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Comments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Stocks");
|
|
}
|
|
}
|
|
}
|