113 lines
3.4 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AAIntegration.SimmonsBank.API.Migrations
{
/// <inheritdoc />
public partial class removedOwner : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Accounts_Users_OwnerId",
table: "Accounts");
migrationBuilder.DropForeignKey(
name: "FK_Transactions_Users_OwnerId",
table: "Transactions");
migrationBuilder.DropIndex(
name: "IX_Transactions_OwnerId",
table: "Transactions");
migrationBuilder.DropIndex(
name: "IX_Accounts_OwnerId",
table: "Accounts");
migrationBuilder.DropColumn(
name: "OwnerId",
table: "Transactions");
migrationBuilder.DropColumn(
name: "OwnerId",
table: "Accounts");
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "Accounts",
type: "integer",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_UserId",
table: "Accounts",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_Accounts_Users_UserId",
table: "Accounts",
column: "UserId",
principalTable: "Users",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Accounts_Users_UserId",
table: "Accounts");
migrationBuilder.DropIndex(
name: "IX_Accounts_UserId",
table: "Accounts");
migrationBuilder.DropColumn(
name: "UserId",
table: "Accounts");
migrationBuilder.AddColumn<int>(
name: "OwnerId",
table: "Transactions",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "OwnerId",
table: "Accounts",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Transactions_OwnerId",
table: "Transactions",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_Accounts_OwnerId",
table: "Accounts",
column: "OwnerId");
migrationBuilder.AddForeignKey(
name: "FK_Accounts_Users_OwnerId",
table: "Accounts",
column: "OwnerId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Transactions_Users_OwnerId",
table: "Transactions",
column: "OwnerId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}