97 lines
4.0 KiB
C#
97 lines
4.0 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using System;
|
|
|
|
namespace IO.Swagger.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Startedtransactionsandcurrencies : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
_ = migrationBuilder.CreateTable(
|
|
name: "Currencies",
|
|
columns: table => new
|
|
{
|
|
CurrencyId = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
|
|
Symbol = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: true),
|
|
UserId = table.Column<int>(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<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FromUserId = table.Column<int>(type: "int", nullable: false),
|
|
ToUserId = table.Column<int>(type: "int", nullable: false),
|
|
Amount = table.Column<float>(type: "real", nullable: false),
|
|
Memo = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false),
|
|
CurrencyId = table.Column<int>(type: "int", nullable: false),
|
|
TransactionTime = table.Column<DateTime>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
_ = migrationBuilder.DropTable(
|
|
name: "Transactions");
|
|
|
|
_ = migrationBuilder.DropTable(
|
|
name: "Currencies");
|
|
}
|
|
}
|
|
}
|