feat(sentiment): dynamic settings, IFinlyticLogger, live log streaming, and EF migration
This commit is contained in:
@@ -1,23 +1,33 @@
|
||||
using FinlyticCore.Database;
|
||||
using FinlyticCore.Entities.Settings;
|
||||
using FinlyticSentiment.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace FinlyticSentiment.Database;
|
||||
|
||||
/// <summary>
|
||||
/// EF Core DbContext for managing FinlyticSentiment settings in PostgreSQL.
|
||||
/// </summary>
|
||||
public class SentimentDbContext : DbContext
|
||||
public class SentimentDbContext : DbContext, ISettingsDbContext
|
||||
{
|
||||
public SentimentDbContext(DbContextOptions<SentimentDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<SettingEntity> DynamicSettings => Set<SettingEntity>();
|
||||
public DbSet<SentimentSettingsEntity> Settings => Set<SentimentSettingsEntity>();
|
||||
|
||||
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<SentimentSettingsEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sentiment_settings");
|
||||
@@ -27,3 +37,13 @@ public class SentimentDbContext : DbContext
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SentimentDbContextFactory : IDesignTimeDbContextFactory<SentimentDbContext>
|
||||
{
|
||||
public SentimentDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<SentimentDbContext>();
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Database=sentiment;Username=postgres;Password=postgres");
|
||||
return new SentimentDbContext(optionsBuilder.Options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user