83 lines
2.5 KiB
C#
83 lines
2.5 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace AAIntegration.SimmonsBank.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class UserOwnedEntities : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
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);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(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");
|
|
}
|
|
}
|
|
}
|