gehgassi_backend/gehGassi.Persistence/Migrations/20230309141120_CardsAdded.cs

109 lines
4.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace gehGassi.Persistence.Migrations
{
/// <inheritdoc />
public partial class CardsAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
AppUserId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
MangoPayId = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
MangoPayUserId = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
ExpirationMonth = table.Column<int>(type: "int", nullable: false),
ExpirationYear = table.Column<int>(type: "int", nullable: false),
CardNumber = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Type = table.Column<int>(type: "int", nullable: false),
CardProvider = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Validity = table.Column<int>(type: "int", nullable: false),
Currency = table.Column<string>(type: "nvarchar(3)", maxLength: 3, nullable: false),
Active = table.Column<bool>(type: "bit", nullable: false),
Created = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Index = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Version = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Deleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
table.ForeignKey(
name: "FK_Cards_AppUsers_AppUserId",
column: x => x.AppUserId,
principalTable: "AppUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Payouts_AppUserId",
table: "Payouts",
column: "AppUserId");
migrationBuilder.CreateIndex(
name: "IX_IdentityDocuments_AppUserId",
table: "IdentityDocuments",
column: "AppUserId");
migrationBuilder.CreateIndex(
name: "IX_Cards_AppUserId",
table: "Cards",
column: "AppUserId");
migrationBuilder.CreateIndex(
name: "IX_Cards_Index",
table: "Cards",
column: "Index");
migrationBuilder.AddForeignKey(
name: "FK_IdentityDocuments_AppUsers_AppUserId",
table: "IdentityDocuments",
column: "AppUserId",
principalTable: "AppUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Payouts_AppUsers_AppUserId",
table: "Payouts",
column: "AppUserId",
principalTable: "AppUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityDocuments_AppUsers_AppUserId",
table: "IdentityDocuments");
migrationBuilder.DropForeignKey(
name: "FK_Payouts_AppUsers_AppUserId",
table: "Payouts");
migrationBuilder.DropTable(
name: "Cards");
migrationBuilder.DropIndex(
name: "IX_Payouts_AppUserId",
table: "Payouts");
migrationBuilder.DropIndex(
name: "IX_IdentityDocuments_AppUserId",
table: "IdentityDocuments");
}
}
}