Added Owner property to account and transaction entities
This commit is contained in:
parent
b81d0cf0bd
commit
dee572f013
@ -8,4 +8,5 @@ public class Account
|
||||
public string Name { get; set; }
|
||||
public decimal Balance { get; set; }
|
||||
public string ExternalAccountNumber { get; set; }
|
||||
public User Owner { get; set; }
|
||||
}
|
@ -15,4 +15,5 @@ public class Transaction
|
||||
public Account? CreditAccount { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public bool IsPending { get; set; }
|
||||
public User Owner { get; set; }
|
||||
}
|
173
AAIntegration.SimmonsBank.API/Migrations/20240320022712_UserOwnedEntities.Designer.cs
generated
Normal file
173
AAIntegration.SimmonsBank.API/Migrations/20240320022712_UserOwnedEntities.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AAIntegration.SimmonsBank.API.Config;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AAIntegration.SimmonsBank.API.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataContext))]
|
||||
[Migration("20240320022712_UserOwnedEntities")]
|
||||
partial class UserOwnedEntities
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.9")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.Account", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<decimal>("Balance")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<string>("ExternalAccountNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("OwnerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.Transaction", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<decimal>("Amount")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<DateTime>("CreatedOn")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("CreditAccountId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("DebitAccountId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ExternalId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsPending")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("OwnerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("UpdatedOn")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CreditAccountId");
|
||||
|
||||
b.HasIndex("DebitAccountId");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ApiKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MFAKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("SimmonsBankPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("SimmonsBankUsername")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.Account", b =>
|
||||
{
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.User", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.Transaction", b =>
|
||||
{
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.Account", "CreditAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreditAccountId");
|
||||
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.Account", "DebitAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("DebitAccountId");
|
||||
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.User", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CreditAccount");
|
||||
|
||||
b.Navigation("DebitAccount");
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
@ -41,8 +41,13 @@ namespace AAIntegration.SimmonsBank.API.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("OwnerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
@ -80,6 +85,9 @@ namespace AAIntegration.SimmonsBank.API.Migrations
|
||||
b.Property<bool>("IsPending")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("OwnerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("UpdatedOn")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@ -89,6 +97,8 @@ namespace AAIntegration.SimmonsBank.API.Migrations
|
||||
|
||||
b.HasIndex("DebitAccountId");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Transactions");
|
||||
});
|
||||
|
||||
@ -121,6 +131,17 @@ namespace AAIntegration.SimmonsBank.API.Migrations
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.Account", b =>
|
||||
{
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.User", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AAIntegration.SimmonsBank.API.Entities.Transaction", b =>
|
||||
{
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.Account", "CreditAccount")
|
||||
@ -131,9 +152,17 @@ namespace AAIntegration.SimmonsBank.API.Migrations
|
||||
.WithMany()
|
||||
.HasForeignKey("DebitAccountId");
|
||||
|
||||
b.HasOne("AAIntegration.SimmonsBank.API.Entities.User", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CreditAccount");
|
||||
|
||||
b.Navigation("DebitAccount");
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user