feat(assets): dynamic settings, IFinlyticLogger, live log streaming, and EF migration
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user