feat(backend): add admin evaluation history, engine, simulation, bot API controllers and global exception middleware
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
using FinlyticBackend.Entities;
|
||||
using FinlyticCore.Database;
|
||||
using FinlyticCore.Entities.Settings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace FinlyticBackend.Database;
|
||||
|
||||
public class BackendDbContext : DbContext
|
||||
/// <summary>
|
||||
/// FinlyticBackend previously implemented no <see cref="ISettingsDbContext"/> at all, unlike every other
|
||||
/// service - which is why it never had dynamic settings (logging channels etc.) to show in the admin UI.
|
||||
/// </summary>
|
||||
public class BackendDbContext : DbContext, ISettingsDbContext
|
||||
{
|
||||
public BackendDbContext(DbContextOptions<BackendDbContext> options) : base(options) { }
|
||||
|
||||
@@ -11,11 +18,18 @@ public class BackendDbContext : DbContext
|
||||
public DbSet<UserDeviceTokenEntity> UserDeviceTokens => Set<UserDeviceTokenEntity>();
|
||||
public DbSet<UserFavoriteAssetEntity> UserFavoriteAssets => Set<UserFavoriteAssetEntity>();
|
||||
public DbSet<ServiceConfigurationEntity> ServiceConfigurations => Set<ServiceConfigurationEntity>();
|
||||
public DbSet<SettingEntity> DynamicSettings => Set<SettingEntity>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<SettingEntity>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.HasIndex(e => e.Key).IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<UserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("users");
|
||||
@@ -73,3 +87,19 @@ public class BackendDbContext : DbContext
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lets `dotnet ef migrations add` construct a <see cref="BackendDbContext"/> without booting the full
|
||||
/// application (which fails fast at startup if JWT_SECRET_KEY/ADMIN_DEFAULT_PASSWORD aren't set - see
|
||||
/// Program.cs) - the same pattern every other service's DbContext already uses
|
||||
/// (e.g. <c>TechnicalAnalysisDbContextFactory</c>).
|
||||
/// </summary>
|
||||
public class BackendDbContextFactory : IDesignTimeDbContextFactory<BackendDbContext>
|
||||
{
|
||||
public BackendDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<BackendDbContext>();
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Database=finlytic_backend;Username=postgres;Password=postgres");
|
||||
return new BackendDbContext(optionsBuilder.Options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user