using Microsoft.EntityFrameworkCore.Migrations; using System; namespace IO.Swagger.Migrations { /// public partial class Startedtransactionsandcurrencies : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { _ = migrationBuilder.CreateTable( name: "Currencies", columns: table => new { CurrencyId = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: true), Symbol = table.Column(type: "nvarchar(4)", maxLength: 4, nullable: true), UserId = table.Column(type: "int", nullable: false) }, constraints: table => { _ = table.PrimaryKey("PK_Currencies", x => x.CurrencyId); _ = table.ForeignKey( name: "FK_Currencies_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id"); }); _ = migrationBuilder.CreateTable( name: "Transactions", columns: table => new { TransactionId = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), FromUserId = table.Column(type: "int", nullable: false), ToUserId = table.Column(type: "int", nullable: false), Amount = table.Column(type: "real", nullable: false), Memo = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), CurrencyId = table.Column(type: "int", nullable: false), TransactionTime = table.Column(type: "datetime2", nullable: false) }, constraints: table => { _ = table.PrimaryKey("PK_Transactions", x => x.TransactionId); _ = table.ForeignKey( name: "FK_Transactions_Currencies_CurrencyId", column: x => x.CurrencyId, principalTable: "Currencies", principalColumn: "CurrencyId"); _ = table.ForeignKey( name: "FK_Transactions_Users_FromUserId", column: x => x.FromUserId, principalTable: "Users", principalColumn: "Id"); _ = table.ForeignKey( name: "FK_Transactions_Users_ToUserId", column: x => x.ToUserId, principalTable: "Users", principalColumn: "Id"); }); _ = migrationBuilder.CreateIndex( name: "IX_Currencies_UserId", table: "Currencies", column: "UserId"); _ = migrationBuilder.CreateIndex( name: "IX_Transactions_CurrencyId", table: "Transactions", column: "CurrencyId"); _ = migrationBuilder.CreateIndex( name: "IX_Transactions_FromUserId", table: "Transactions", column: "FromUserId"); _ = migrationBuilder.CreateIndex( name: "IX_Transactions_ToUserId", table: "Transactions", column: "ToUserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { _ = migrationBuilder.DropTable( name: "Transactions"); _ = migrationBuilder.DropTable( name: "Currencies"); } } }