Files
oemanxTrader/OemanTrader.EntityFramework/Migrations/20220508202548_initial.cs
2022-05-26 15:19:31 +02:00

96 lines
3.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace OemanTrader.EntityFramework.Migrations
{
public partial class initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateJoined = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountHolderId = table.Column<int>(type: "int", nullable: false),
Balance = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_Users_AccountHolderId",
column: x => x.AccountHolderId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AssetTransactions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountId = table.Column<int>(type: "int", nullable: false),
IsPurchase = table.Column<bool>(type: "bit", nullable: false),
Stock_Symbol = table.Column<string>(type: "nvarchar(max)", nullable: false),
Stock_PricePerShare = table.Column<double>(type: "float", nullable: false),
ShareAmount = table.Column<int>(type: "int", nullable: false),
DateProcessed = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AssetTransactions", x => x.Id);
table.ForeignKey(
name: "FK_AssetTransactions_Accounts_AccountId",
column: x => x.AccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Accounts_AccountHolderId",
table: "Accounts",
column: "AccountHolderId");
migrationBuilder.CreateIndex(
name: "IX_AssetTransactions_AccountId",
table: "AssetTransactions",
column: "AccountId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AssetTransactions");
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropTable(
name: "Users");
}
}
}