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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Email = table.Column(type: "nvarchar(max)", nullable: false), UserName = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), DateJoined = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AccountHolderId = table.Column(type: "int", nullable: false), Balance = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AccountId = table.Column(type: "int", nullable: false), IsPurchase = table.Column(type: "bit", nullable: false), Stock_Symbol = table.Column(type: "nvarchar(max)", nullable: false), Stock_PricePerShare = table.Column(type: "float", nullable: false), ShareAmount = table.Column(type: "int", nullable: false), DateProcessed = table.Column(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"); } } }