mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 18:11:10 +00:00
Adds the scheduled jobs data access layer
This commit is contained in:
1 parent
ea7e003bff
commit
bb16cd0bb6
9 files changed
+2382
-6
No files matched your search
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="ScheduledJobExecutionEntity"/> entity.
|
||||
/// </summary>
|
||||
public class ScheduledJobExecutionConfiguration : IEntityTypeConfiguration<ScheduledJobExecutionEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="ScheduledJobExecutionEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<ScheduledJobExecutionEntity> builder)
|
||||
{
|
||||
builder.ToTable("ScheduledJobExecutions");
|
||||
builder.HasKey(execution => execution.Id);
|
||||
builder.Property(execution => execution.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(execution => execution.ScheduledJobId)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
|
||||
builder.Property(execution => execution.TaskType)
|
||||
.IsRequired()
|
||||
.HasConversion<string>()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(execution => execution.IsCycleRun)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(execution => execution.StartedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(execution => execution.CompletedOnUtc)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
// Audit.
|
||||
builder.Property(execution => execution.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(6);
|
||||
|
||||
builder.Property(execution => execution.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(7);
|
||||
|
||||
builder.Property(execution => execution.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
builder.Property(execution => execution.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(9);
|
||||
|
||||
// Enables fast queries of the execution history of scheduled jobs by their time range, and the cleanup of the executions of a removed scheduled job.
|
||||
builder.HasIndex(execution => new { execution.StartedOnUtc, execution.ScheduledJobId });
|
||||
builder.HasIndex(execution => execution.ScheduledJobId);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user