feat(assets): dynamic settings, IFinlyticLogger, live log streaming, and EF migration

This commit is contained in:
2026-08-15 21:30:46 +02:00
parent 57554a9582
commit 1f9d66405a
11 changed files with 855 additions and 384 deletions
+17 -3
View File
@@ -1,11 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FinlyticAssets.Entities;
using FinlyticCore.Database;
using FinlyticCore.Entities.Settings;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Design;
namespace FinlyticAssets.Database;
public class AssetsDbContext : DbContext
public class AssetsDbContext : DbContext, ISettingsDbContext
{
public AssetsDbContext(DbContextOptions<AssetsDbContext> options) : base(options)
{
@@ -16,7 +21,6 @@ public class AssetsDbContext : DbContext
public DbSet<AssetEntity> TradeRepublicAssets { get; set; }
public DbSet<TagEntity> TradeRepublicTags { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
@@ -24,7 +28,7 @@ public class AssetsDbContext : DbContext
modelBuilder.Entity<SettingEntity>(entity =>
{
entity.HasKey(e => e.Id);
entity.HasIndex(e => e.Key);
entity.HasIndex(e => e.Key).IsUnique();
});
modelBuilder.Entity<AssetEntity>(entity =>
{
@@ -95,3 +99,13 @@ public class AssetsDbContext : DbContext
.HaveConversion(typeof(FinlyticCore.Converters.NullableUtcDateTimeConverter));
}
}
public class AssetsDbContextFactory : IDesignTimeDbContextFactory<AssetsDbContext>
{
public AssetsDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<AssetsDbContext>();
optionsBuilder.UseNpgsql("Host=localhost;Database=assets;Username=postgres;Password=postgres");
return new AssetsDbContext(optionsBuilder.Options);
}
}