[FA-misc] Add Job entity and ReportingDbContext
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using FictionArchive.Service.ReportingService.Models;
|
||||
using FictionArchive.Service.Shared.Services.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Services;
|
||||
|
||||
public class ReportingDbContext : FictionArchiveDbContext
|
||||
{
|
||||
public DbSet<Job> Jobs { get; set; }
|
||||
|
||||
public ReportingDbContext(DbContextOptions options, ILogger<ReportingDbContext> logger) : base(options, logger)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Job>(entity =>
|
||||
{
|
||||
entity.HasIndex(j => j.ParentJobId);
|
||||
|
||||
entity.Property(j => j.Metadata)
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
entity.HasOne(j => j.ParentJob)
|
||||
.WithMany(j => j.ChildJobs)
|
||||
.HasForeignKey(j => j.ParentJobId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user