Updated ef migrations.

This commit is contained in:
2026-07-29 13:03:30 +02:00
parent 44846eaa13
commit acc8423fc6
10 changed files with 410 additions and 22 deletions
@@ -0,0 +1,114 @@
// <auto-generated />
using System;
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
[Migration("20260729103021_AccountTypes")]
partial class AccountTypes
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Domain.Entities.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
Balance = 10000000.00m,
Type = 2
},
new
{
Id = 2,
Balance = 50000000.00m,
Type = 0
},
new
{
Id = 99999,
Balance = 0.00m,
Type = 3
});
});
modelBuilder.Entity("FinancialApi.Domain.Entities.JournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Domain.Entities.JournalEntry", b =>
{
b.OwnsMany("FinancialApi.Domain.Entities.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("AccountId")
.HasColumnType("INTEGER");
b1.Property<decimal>("Amount")
.HasColumnType("TEXT");
b1.Property<Guid>("JournalEntryId")
.HasColumnType("TEXT");
b1.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b1.HasKey("Id");
b1.HasIndex("JournalEntryId");
b1.ToTable("JournalLine");
b1.WithOwner()
.HasForeignKey("JournalEntryId");
});
b.Navigation("Lines");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AccountTypes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AccountType",
table: "Accounts");
migrationBuilder.AddColumn<int>(
name: "Type",
table: "Accounts",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "Type",
value: 2);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "Type",
value: 0);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999,
column: "Type",
value: 3);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Type",
table: "Accounts");
migrationBuilder.AddColumn<string>(
name: "AccountType",
table: "Accounts",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "AccountType",
value: "Credit");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "AccountType",
value: "Liability");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999,
column: "AccountType",
value: "Revenue");
}
}
}
@@ -17,19 +17,18 @@ namespace FinancialApi.Infrastructure.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Application.Account", b =>
modelBuilder.Entity("FinancialApi.Domain.Entities.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AccountType")
.IsRequired()
.HasColumnType("TEXT");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Accounts");
@@ -38,24 +37,24 @@ namespace FinancialApi.Infrastructure.Migrations
new
{
Id = 1,
AccountType = "Credit",
Balance = 10000000.00m
Balance = 10000000.00m,
Type = 2
},
new
{
Id = 2,
AccountType = "Liability",
Balance = 50000000.00m
Balance = 50000000.00m,
Type = 0
},
new
{
Id = 99999,
AccountType = "Revenue",
Balance = 0.00m
Balance = 0.00m,
Type = 3
});
});
modelBuilder.Entity("FinancialApi.Application.JournalEntry", b =>
modelBuilder.Entity("FinancialApi.Domain.Entities.JournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -73,9 +72,9 @@ namespace FinancialApi.Infrastructure.Migrations
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Application.JournalEntry", b =>
modelBuilder.Entity("FinancialApi.Domain.Entities.JournalEntry", b =>
{
b.OwnsMany("FinancialApi.Application.JournalLine", "Lines", b1 =>
b.OwnsMany("FinancialApi.Domain.Entities.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()