[FA-misc] Mass transit overhaul, needs testing and review
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using FictionArchive.Service.ReportingService.Models.Database;
|
||||
using FictionArchive.Service.Shared.Services.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Services;
|
||||
|
||||
public class ReportingServiceDbContext : FictionArchiveDbContext
|
||||
{
|
||||
public ReportingServiceDbContext(DbContextOptions options, ILogger<ReportingServiceDbContext> logger)
|
||||
: base(options, logger) { }
|
||||
|
||||
public DbSet<Job> Jobs => Set<Job>();
|
||||
public DbSet<JobHistoryEntry> JobHistoryEntries => Set<JobHistoryEntry>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Job>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.HasIndex(e => e.JobType);
|
||||
entity.HasIndex(e => e.Status);
|
||||
entity.HasIndex(e => e.CreatedTime);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<JobHistoryEntry>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.HasOne(e => e.Job)
|
||||
.WithMany(j => j.History)
|
||||
.HasForeignKey(e => e.JobId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user