[FA-9] Postgres backing works

This commit is contained in:
gamer147
2025-11-20 13:53:58 -05:00
parent 0abb10bb00
commit 3250cf1467
8 changed files with 1508 additions and 2 deletions

View File

@@ -18,9 +18,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AppAny.Quartz.EntityFrameworkCore.Migrations.PostgreSQL" Version="0.5.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Quartz" Version="3.15.1" /> <PackageReference Include="Quartz" Version="3.15.1" />
<PackageReference Include="Quartz.AspNetCore" Version="3.15.1" /> <PackageReference Include="Quartz.AspNetCore" Version="3.15.1" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.15.1" /> <PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.15.1" />
<PackageReference Include="Quartz.Serialization.Json" Version="3.15.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -27,7 +27,7 @@ public class Mutation
bool deleted = await jobManager.DeleteJob(jobKey); bool deleted = await jobManager.DeleteJob(jobKey);
if (!deleted) if (!deleted)
{ {
throw new KeyNotFoundException($"Job with key {jobKey} was not found"); throw new KeyNotFoundException($"Job with key '{jobKey}' was not found");
} }
return true; return true;

View File

@@ -0,0 +1,543 @@
// <auto-generated />
using FictionArchive.Service.SchedulerService.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FictionArchive.Service.SchedulerService.Migrations
{
[DbContext(typeof(SchedulerServiceDbContext))]
[Migration("20251120151130_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzBlobTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<byte[]>("BlobData")
.HasColumnType("bytea")
.HasColumnName("blob_data");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_blob_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzCalendar", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("CalendarName")
.HasColumnType("text")
.HasColumnName("calendar_name");
b.Property<byte[]>("Calendar")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("calendar");
b.HasKey("SchedulerName", "CalendarName");
b.ToTable("qrtz_calendars", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzCronTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<string>("CronExpression")
.IsRequired()
.HasColumnType("text")
.HasColumnName("cron_expression");
b.Property<string>("TimeZoneId")
.HasColumnType("text")
.HasColumnName("time_zone_id");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_cron_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzFiredTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("EntryId")
.HasColumnType("text")
.HasColumnName("entry_id");
b.Property<long>("FiredTime")
.HasColumnType("bigint")
.HasColumnName("fired_time");
b.Property<string>("InstanceName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("instance_name");
b.Property<bool>("IsNonConcurrent")
.HasColumnType("bool")
.HasColumnName("is_nonconcurrent");
b.Property<string>("JobGroup")
.HasColumnType("text")
.HasColumnName("job_group");
b.Property<string>("JobName")
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<int>("Priority")
.HasColumnType("integer")
.HasColumnName("priority");
b.Property<bool?>("RequestsRecovery")
.HasColumnType("bool")
.HasColumnName("requests_recovery");
b.Property<long>("ScheduledTime")
.HasColumnType("bigint")
.HasColumnName("sched_time");
b.Property<string>("State")
.IsRequired()
.HasColumnType("text")
.HasColumnName("state");
b.Property<string>("TriggerGroup")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<string>("TriggerName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_name");
b.HasKey("SchedulerName", "EntryId");
b.HasIndex("InstanceName")
.HasDatabaseName("idx_qrtz_ft_trig_inst_name");
b.HasIndex("JobGroup")
.HasDatabaseName("idx_qrtz_ft_job_group");
b.HasIndex("JobName")
.HasDatabaseName("idx_qrtz_ft_job_name");
b.HasIndex("RequestsRecovery")
.HasDatabaseName("idx_qrtz_ft_job_req_recovery");
b.HasIndex("TriggerGroup")
.HasDatabaseName("idx_qrtz_ft_trig_group");
b.HasIndex("TriggerName")
.HasDatabaseName("idx_qrtz_ft_trig_name");
b.HasIndex("SchedulerName", "TriggerName", "TriggerGroup")
.HasDatabaseName("idx_qrtz_ft_trig_nm_gp");
b.ToTable("qrtz_fired_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzJobDetail", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("JobName")
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<string>("JobGroup")
.HasColumnType("text")
.HasColumnName("job_group");
b.Property<string>("Description")
.HasColumnType("text")
.HasColumnName("description");
b.Property<bool>("IsDurable")
.HasColumnType("bool")
.HasColumnName("is_durable");
b.Property<bool>("IsNonConcurrent")
.HasColumnType("bool")
.HasColumnName("is_nonconcurrent");
b.Property<bool>("IsUpdateData")
.HasColumnType("bool")
.HasColumnName("is_update_data");
b.Property<string>("JobClassName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_class_name");
b.Property<byte[]>("JobData")
.HasColumnType("bytea")
.HasColumnName("job_data");
b.Property<bool>("RequestsRecovery")
.HasColumnType("bool")
.HasColumnName("requests_recovery");
b.HasKey("SchedulerName", "JobName", "JobGroup");
b.HasIndex("RequestsRecovery")
.HasDatabaseName("idx_qrtz_j_req_recovery");
b.ToTable("qrtz_job_details", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzLock", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("LockName")
.HasColumnType("text")
.HasColumnName("lock_name");
b.HasKey("SchedulerName", "LockName");
b.ToTable("qrtz_locks", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzPausedTriggerGroup", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.HasKey("SchedulerName", "TriggerGroup");
b.ToTable("qrtz_paused_trigger_grps", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSchedulerState", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("InstanceName")
.HasColumnType("text")
.HasColumnName("instance_name");
b.Property<long>("CheckInInterval")
.HasColumnType("bigint")
.HasColumnName("checkin_interval");
b.Property<long>("LastCheckInTime")
.HasColumnType("bigint")
.HasColumnName("last_checkin_time");
b.HasKey("SchedulerName", "InstanceName");
b.ToTable("qrtz_scheduler_state", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimplePropertyTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<bool?>("BooleanProperty1")
.HasColumnType("bool")
.HasColumnName("bool_prop_1");
b.Property<bool?>("BooleanProperty2")
.HasColumnType("bool")
.HasColumnName("bool_prop_2");
b.Property<decimal?>("DecimalProperty1")
.HasColumnType("numeric")
.HasColumnName("dec_prop_1");
b.Property<decimal?>("DecimalProperty2")
.HasColumnType("numeric")
.HasColumnName("dec_prop_2");
b.Property<int?>("IntegerProperty1")
.HasColumnType("integer")
.HasColumnName("int_prop_1");
b.Property<int?>("IntegerProperty2")
.HasColumnType("integer")
.HasColumnName("int_prop_2");
b.Property<long?>("LongProperty1")
.HasColumnType("bigint")
.HasColumnName("long_prop_1");
b.Property<long?>("LongProperty2")
.HasColumnType("bigint")
.HasColumnName("long_prop_2");
b.Property<string>("StringProperty1")
.HasColumnType("text")
.HasColumnName("str_prop_1");
b.Property<string>("StringProperty2")
.HasColumnType("text")
.HasColumnName("str_prop_2");
b.Property<string>("StringProperty3")
.HasColumnType("text")
.HasColumnName("str_prop_3");
b.Property<string>("TimeZoneId")
.HasColumnType("text")
.HasColumnName("time_zone_id");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_simprop_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimpleTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<long>("RepeatCount")
.HasColumnType("bigint")
.HasColumnName("repeat_count");
b.Property<long>("RepeatInterval")
.HasColumnType("bigint")
.HasColumnName("repeat_interval");
b.Property<long>("TimesTriggered")
.HasColumnType("bigint")
.HasColumnName("times_triggered");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_simple_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<string>("CalendarName")
.HasColumnType("text")
.HasColumnName("calendar_name");
b.Property<string>("Description")
.HasColumnType("text")
.HasColumnName("description");
b.Property<long?>("EndTime")
.HasColumnType("bigint")
.HasColumnName("end_time");
b.Property<byte[]>("JobData")
.HasColumnType("bytea")
.HasColumnName("job_data");
b.Property<string>("JobGroup")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_group");
b.Property<string>("JobName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<short?>("MisfireInstruction")
.HasColumnType("smallint")
.HasColumnName("misfire_instr");
b.Property<long?>("NextFireTime")
.HasColumnType("bigint")
.HasColumnName("next_fire_time");
b.Property<long?>("PreviousFireTime")
.HasColumnType("bigint")
.HasColumnName("prev_fire_time");
b.Property<int?>("Priority")
.HasColumnType("integer")
.HasColumnName("priority");
b.Property<long>("StartTime")
.HasColumnType("bigint")
.HasColumnName("start_time");
b.Property<string>("TriggerState")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_state");
b.Property<string>("TriggerType")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_type");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.HasIndex("NextFireTime")
.HasDatabaseName("idx_qrtz_t_next_fire_time");
b.HasIndex("TriggerState")
.HasDatabaseName("idx_qrtz_t_state");
b.HasIndex("NextFireTime", "TriggerState")
.HasDatabaseName("idx_qrtz_t_nft_st");
b.HasIndex("SchedulerName", "JobName", "JobGroup");
b.ToTable("qrtz_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzBlobTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("BlobTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzCronTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("CronTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimplePropertyTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("SimplePropertyTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimpleTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("SimpleTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzJobDetail", "JobDetail")
.WithMany("Triggers")
.HasForeignKey("SchedulerName", "JobName", "JobGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("JobDetail");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzJobDetail", b =>
{
b.Navigation("Triggers");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", b =>
{
b.Navigation("BlobTriggers");
b.Navigation("CronTriggers");
b.Navigation("SimplePropertyTriggers");
b.Navigation("SimpleTriggers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,373 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FictionArchive.Service.SchedulerService.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "quartz");
migrationBuilder.CreateTable(
name: "qrtz_calendars",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
calendar_name = table.Column<string>(type: "text", nullable: false),
calendar = table.Column<byte[]>(type: "bytea", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_calendars", x => new { x.sched_name, x.calendar_name });
});
migrationBuilder.CreateTable(
name: "qrtz_fired_triggers",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
entry_id = table.Column<string>(type: "text", nullable: false),
trigger_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false),
instance_name = table.Column<string>(type: "text", nullable: false),
fired_time = table.Column<long>(type: "bigint", nullable: false),
sched_time = table.Column<long>(type: "bigint", nullable: false),
priority = table.Column<int>(type: "integer", nullable: false),
state = table.Column<string>(type: "text", nullable: false),
job_name = table.Column<string>(type: "text", nullable: true),
job_group = table.Column<string>(type: "text", nullable: true),
is_nonconcurrent = table.Column<bool>(type: "bool", nullable: false),
requests_recovery = table.Column<bool>(type: "bool", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_fired_triggers", x => new { x.sched_name, x.entry_id });
});
migrationBuilder.CreateTable(
name: "qrtz_job_details",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
job_name = table.Column<string>(type: "text", nullable: false),
job_group = table.Column<string>(type: "text", nullable: false),
description = table.Column<string>(type: "text", nullable: true),
job_class_name = table.Column<string>(type: "text", nullable: false),
is_durable = table.Column<bool>(type: "bool", nullable: false),
is_nonconcurrent = table.Column<bool>(type: "bool", nullable: false),
is_update_data = table.Column<bool>(type: "bool", nullable: false),
requests_recovery = table.Column<bool>(type: "bool", nullable: false),
job_data = table.Column<byte[]>(type: "bytea", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_job_details", x => new { x.sched_name, x.job_name, x.job_group });
});
migrationBuilder.CreateTable(
name: "qrtz_locks",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
lock_name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_locks", x => new { x.sched_name, x.lock_name });
});
migrationBuilder.CreateTable(
name: "qrtz_paused_trigger_grps",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_paused_trigger_grps", x => new { x.sched_name, x.trigger_group });
});
migrationBuilder.CreateTable(
name: "qrtz_scheduler_state",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
instance_name = table.Column<string>(type: "text", nullable: false),
last_checkin_time = table.Column<long>(type: "bigint", nullable: false),
checkin_interval = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_scheduler_state", x => new { x.sched_name, x.instance_name });
});
migrationBuilder.CreateTable(
name: "qrtz_triggers",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
trigger_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false),
job_name = table.Column<string>(type: "text", nullable: false),
job_group = table.Column<string>(type: "text", nullable: false),
description = table.Column<string>(type: "text", nullable: true),
next_fire_time = table.Column<long>(type: "bigint", nullable: true),
prev_fire_time = table.Column<long>(type: "bigint", nullable: true),
priority = table.Column<int>(type: "integer", nullable: true),
trigger_state = table.Column<string>(type: "text", nullable: false),
trigger_type = table.Column<string>(type: "text", nullable: false),
start_time = table.Column<long>(type: "bigint", nullable: false),
end_time = table.Column<long>(type: "bigint", nullable: true),
calendar_name = table.Column<string>(type: "text", nullable: true),
misfire_instr = table.Column<short>(type: "smallint", nullable: true),
job_data = table.Column<byte[]>(type: "bytea", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_triggers", x => new { x.sched_name, x.trigger_name, x.trigger_group });
table.ForeignKey(
name: "FK_qrtz_triggers_qrtz_job_details_sched_name_job_name_job_group",
columns: x => new { x.sched_name, x.job_name, x.job_group },
principalSchema: "quartz",
principalTable: "qrtz_job_details",
principalColumns: new[] { "sched_name", "job_name", "job_group" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "qrtz_blob_triggers",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
trigger_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false),
blob_data = table.Column<byte[]>(type: "bytea", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_blob_triggers", x => new { x.sched_name, x.trigger_name, x.trigger_group });
table.ForeignKey(
name: "FK_qrtz_blob_triggers_qrtz_triggers_sched_name_trigger_name_tr~",
columns: x => new { x.sched_name, x.trigger_name, x.trigger_group },
principalSchema: "quartz",
principalTable: "qrtz_triggers",
principalColumns: new[] { "sched_name", "trigger_name", "trigger_group" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "qrtz_cron_triggers",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
trigger_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false),
cron_expression = table.Column<string>(type: "text", nullable: false),
time_zone_id = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_cron_triggers", x => new { x.sched_name, x.trigger_name, x.trigger_group });
table.ForeignKey(
name: "FK_qrtz_cron_triggers_qrtz_triggers_sched_name_trigger_name_tr~",
columns: x => new { x.sched_name, x.trigger_name, x.trigger_group },
principalSchema: "quartz",
principalTable: "qrtz_triggers",
principalColumns: new[] { "sched_name", "trigger_name", "trigger_group" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "qrtz_simple_triggers",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
trigger_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false),
repeat_count = table.Column<long>(type: "bigint", nullable: false),
repeat_interval = table.Column<long>(type: "bigint", nullable: false),
times_triggered = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_simple_triggers", x => new { x.sched_name, x.trigger_name, x.trigger_group });
table.ForeignKey(
name: "FK_qrtz_simple_triggers_qrtz_triggers_sched_name_trigger_name_~",
columns: x => new { x.sched_name, x.trigger_name, x.trigger_group },
principalSchema: "quartz",
principalTable: "qrtz_triggers",
principalColumns: new[] { "sched_name", "trigger_name", "trigger_group" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "qrtz_simprop_triggers",
schema: "quartz",
columns: table => new
{
sched_name = table.Column<string>(type: "text", nullable: false),
trigger_name = table.Column<string>(type: "text", nullable: false),
trigger_group = table.Column<string>(type: "text", nullable: false),
str_prop_1 = table.Column<string>(type: "text", nullable: true),
str_prop_2 = table.Column<string>(type: "text", nullable: true),
str_prop_3 = table.Column<string>(type: "text", nullable: true),
int_prop_1 = table.Column<int>(type: "integer", nullable: true),
int_prop_2 = table.Column<int>(type: "integer", nullable: true),
long_prop_1 = table.Column<long>(type: "bigint", nullable: true),
long_prop_2 = table.Column<long>(type: "bigint", nullable: true),
dec_prop_1 = table.Column<decimal>(type: "numeric", nullable: true),
dec_prop_2 = table.Column<decimal>(type: "numeric", nullable: true),
bool_prop_1 = table.Column<bool>(type: "bool", nullable: true),
bool_prop_2 = table.Column<bool>(type: "bool", nullable: true),
time_zone_id = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_qrtz_simprop_triggers", x => new { x.sched_name, x.trigger_name, x.trigger_group });
table.ForeignKey(
name: "FK_qrtz_simprop_triggers_qrtz_triggers_sched_name_trigger_name~",
columns: x => new { x.sched_name, x.trigger_name, x.trigger_group },
principalSchema: "quartz",
principalTable: "qrtz_triggers",
principalColumns: new[] { "sched_name", "trigger_name", "trigger_group" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_job_group",
schema: "quartz",
table: "qrtz_fired_triggers",
column: "job_group");
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_job_name",
schema: "quartz",
table: "qrtz_fired_triggers",
column: "job_name");
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_job_req_recovery",
schema: "quartz",
table: "qrtz_fired_triggers",
column: "requests_recovery");
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_trig_group",
schema: "quartz",
table: "qrtz_fired_triggers",
column: "trigger_group");
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_trig_inst_name",
schema: "quartz",
table: "qrtz_fired_triggers",
column: "instance_name");
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_trig_name",
schema: "quartz",
table: "qrtz_fired_triggers",
column: "trigger_name");
migrationBuilder.CreateIndex(
name: "idx_qrtz_ft_trig_nm_gp",
schema: "quartz",
table: "qrtz_fired_triggers",
columns: new[] { "sched_name", "trigger_name", "trigger_group" });
migrationBuilder.CreateIndex(
name: "idx_qrtz_j_req_recovery",
schema: "quartz",
table: "qrtz_job_details",
column: "requests_recovery");
migrationBuilder.CreateIndex(
name: "idx_qrtz_t_next_fire_time",
schema: "quartz",
table: "qrtz_triggers",
column: "next_fire_time");
migrationBuilder.CreateIndex(
name: "idx_qrtz_t_nft_st",
schema: "quartz",
table: "qrtz_triggers",
columns: new[] { "next_fire_time", "trigger_state" });
migrationBuilder.CreateIndex(
name: "idx_qrtz_t_state",
schema: "quartz",
table: "qrtz_triggers",
column: "trigger_state");
migrationBuilder.CreateIndex(
name: "IX_qrtz_triggers_sched_name_job_name_job_group",
schema: "quartz",
table: "qrtz_triggers",
columns: new[] { "sched_name", "job_name", "job_group" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "qrtz_blob_triggers",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_calendars",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_cron_triggers",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_fired_triggers",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_locks",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_paused_trigger_grps",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_scheduler_state",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_simple_triggers",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_simprop_triggers",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_triggers",
schema: "quartz");
migrationBuilder.DropTable(
name: "qrtz_job_details",
schema: "quartz");
}
}
}

View File

@@ -0,0 +1,540 @@
// <auto-generated />
using FictionArchive.Service.SchedulerService.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FictionArchive.Service.SchedulerService.Migrations
{
[DbContext(typeof(SchedulerServiceDbContext))]
partial class SchedulerServiceDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzBlobTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<byte[]>("BlobData")
.HasColumnType("bytea")
.HasColumnName("blob_data");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_blob_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzCalendar", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("CalendarName")
.HasColumnType("text")
.HasColumnName("calendar_name");
b.Property<byte[]>("Calendar")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("calendar");
b.HasKey("SchedulerName", "CalendarName");
b.ToTable("qrtz_calendars", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzCronTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<string>("CronExpression")
.IsRequired()
.HasColumnType("text")
.HasColumnName("cron_expression");
b.Property<string>("TimeZoneId")
.HasColumnType("text")
.HasColumnName("time_zone_id");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_cron_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzFiredTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("EntryId")
.HasColumnType("text")
.HasColumnName("entry_id");
b.Property<long>("FiredTime")
.HasColumnType("bigint")
.HasColumnName("fired_time");
b.Property<string>("InstanceName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("instance_name");
b.Property<bool>("IsNonConcurrent")
.HasColumnType("bool")
.HasColumnName("is_nonconcurrent");
b.Property<string>("JobGroup")
.HasColumnType("text")
.HasColumnName("job_group");
b.Property<string>("JobName")
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<int>("Priority")
.HasColumnType("integer")
.HasColumnName("priority");
b.Property<bool?>("RequestsRecovery")
.HasColumnType("bool")
.HasColumnName("requests_recovery");
b.Property<long>("ScheduledTime")
.HasColumnType("bigint")
.HasColumnName("sched_time");
b.Property<string>("State")
.IsRequired()
.HasColumnType("text")
.HasColumnName("state");
b.Property<string>("TriggerGroup")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<string>("TriggerName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_name");
b.HasKey("SchedulerName", "EntryId");
b.HasIndex("InstanceName")
.HasDatabaseName("idx_qrtz_ft_trig_inst_name");
b.HasIndex("JobGroup")
.HasDatabaseName("idx_qrtz_ft_job_group");
b.HasIndex("JobName")
.HasDatabaseName("idx_qrtz_ft_job_name");
b.HasIndex("RequestsRecovery")
.HasDatabaseName("idx_qrtz_ft_job_req_recovery");
b.HasIndex("TriggerGroup")
.HasDatabaseName("idx_qrtz_ft_trig_group");
b.HasIndex("TriggerName")
.HasDatabaseName("idx_qrtz_ft_trig_name");
b.HasIndex("SchedulerName", "TriggerName", "TriggerGroup")
.HasDatabaseName("idx_qrtz_ft_trig_nm_gp");
b.ToTable("qrtz_fired_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzJobDetail", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("JobName")
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<string>("JobGroup")
.HasColumnType("text")
.HasColumnName("job_group");
b.Property<string>("Description")
.HasColumnType("text")
.HasColumnName("description");
b.Property<bool>("IsDurable")
.HasColumnType("bool")
.HasColumnName("is_durable");
b.Property<bool>("IsNonConcurrent")
.HasColumnType("bool")
.HasColumnName("is_nonconcurrent");
b.Property<bool>("IsUpdateData")
.HasColumnType("bool")
.HasColumnName("is_update_data");
b.Property<string>("JobClassName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_class_name");
b.Property<byte[]>("JobData")
.HasColumnType("bytea")
.HasColumnName("job_data");
b.Property<bool>("RequestsRecovery")
.HasColumnType("bool")
.HasColumnName("requests_recovery");
b.HasKey("SchedulerName", "JobName", "JobGroup");
b.HasIndex("RequestsRecovery")
.HasDatabaseName("idx_qrtz_j_req_recovery");
b.ToTable("qrtz_job_details", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzLock", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("LockName")
.HasColumnType("text")
.HasColumnName("lock_name");
b.HasKey("SchedulerName", "LockName");
b.ToTable("qrtz_locks", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzPausedTriggerGroup", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.HasKey("SchedulerName", "TriggerGroup");
b.ToTable("qrtz_paused_trigger_grps", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSchedulerState", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("InstanceName")
.HasColumnType("text")
.HasColumnName("instance_name");
b.Property<long>("CheckInInterval")
.HasColumnType("bigint")
.HasColumnName("checkin_interval");
b.Property<long>("LastCheckInTime")
.HasColumnType("bigint")
.HasColumnName("last_checkin_time");
b.HasKey("SchedulerName", "InstanceName");
b.ToTable("qrtz_scheduler_state", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimplePropertyTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<bool?>("BooleanProperty1")
.HasColumnType("bool")
.HasColumnName("bool_prop_1");
b.Property<bool?>("BooleanProperty2")
.HasColumnType("bool")
.HasColumnName("bool_prop_2");
b.Property<decimal?>("DecimalProperty1")
.HasColumnType("numeric")
.HasColumnName("dec_prop_1");
b.Property<decimal?>("DecimalProperty2")
.HasColumnType("numeric")
.HasColumnName("dec_prop_2");
b.Property<int?>("IntegerProperty1")
.HasColumnType("integer")
.HasColumnName("int_prop_1");
b.Property<int?>("IntegerProperty2")
.HasColumnType("integer")
.HasColumnName("int_prop_2");
b.Property<long?>("LongProperty1")
.HasColumnType("bigint")
.HasColumnName("long_prop_1");
b.Property<long?>("LongProperty2")
.HasColumnType("bigint")
.HasColumnName("long_prop_2");
b.Property<string>("StringProperty1")
.HasColumnType("text")
.HasColumnName("str_prop_1");
b.Property<string>("StringProperty2")
.HasColumnType("text")
.HasColumnName("str_prop_2");
b.Property<string>("StringProperty3")
.HasColumnType("text")
.HasColumnName("str_prop_3");
b.Property<string>("TimeZoneId")
.HasColumnType("text")
.HasColumnName("time_zone_id");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_simprop_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimpleTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<long>("RepeatCount")
.HasColumnType("bigint")
.HasColumnName("repeat_count");
b.Property<long>("RepeatInterval")
.HasColumnType("bigint")
.HasColumnName("repeat_interval");
b.Property<long>("TimesTriggered")
.HasColumnType("bigint")
.HasColumnName("times_triggered");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.ToTable("qrtz_simple_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", b =>
{
b.Property<string>("SchedulerName")
.HasColumnType("text")
.HasColumnName("sched_name");
b.Property<string>("TriggerName")
.HasColumnType("text")
.HasColumnName("trigger_name");
b.Property<string>("TriggerGroup")
.HasColumnType("text")
.HasColumnName("trigger_group");
b.Property<string>("CalendarName")
.HasColumnType("text")
.HasColumnName("calendar_name");
b.Property<string>("Description")
.HasColumnType("text")
.HasColumnName("description");
b.Property<long?>("EndTime")
.HasColumnType("bigint")
.HasColumnName("end_time");
b.Property<byte[]>("JobData")
.HasColumnType("bytea")
.HasColumnName("job_data");
b.Property<string>("JobGroup")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_group");
b.Property<string>("JobName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<short?>("MisfireInstruction")
.HasColumnType("smallint")
.HasColumnName("misfire_instr");
b.Property<long?>("NextFireTime")
.HasColumnType("bigint")
.HasColumnName("next_fire_time");
b.Property<long?>("PreviousFireTime")
.HasColumnType("bigint")
.HasColumnName("prev_fire_time");
b.Property<int?>("Priority")
.HasColumnType("integer")
.HasColumnName("priority");
b.Property<long>("StartTime")
.HasColumnType("bigint")
.HasColumnName("start_time");
b.Property<string>("TriggerState")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_state");
b.Property<string>("TriggerType")
.IsRequired()
.HasColumnType("text")
.HasColumnName("trigger_type");
b.HasKey("SchedulerName", "TriggerName", "TriggerGroup");
b.HasIndex("NextFireTime")
.HasDatabaseName("idx_qrtz_t_next_fire_time");
b.HasIndex("TriggerState")
.HasDatabaseName("idx_qrtz_t_state");
b.HasIndex("NextFireTime", "TriggerState")
.HasDatabaseName("idx_qrtz_t_nft_st");
b.HasIndex("SchedulerName", "JobName", "JobGroup");
b.ToTable("qrtz_triggers", "quartz");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzBlobTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("BlobTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzCronTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("CronTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimplePropertyTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("SimplePropertyTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzSimpleTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", "Trigger")
.WithMany("SimpleTriggers")
.HasForeignKey("SchedulerName", "TriggerName", "TriggerGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Trigger");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", b =>
{
b.HasOne("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzJobDetail", "JobDetail")
.WithMany("Triggers")
.HasForeignKey("SchedulerName", "JobName", "JobGroup")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("JobDetail");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzJobDetail", b =>
{
b.Navigation("Triggers");
});
modelBuilder.Entity("AppAny.Quartz.EntityFrameworkCore.Migrations.QuartzTrigger", b =>
{
b.Navigation("BlobTriggers");
b.Navigation("CronTriggers");
b.Navigation("SimplePropertyTriggers");
b.Navigation("SimpleTriggers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -3,6 +3,7 @@ using FictionArchive.Service.SchedulerService.Services;
using FictionArchive.Service.Shared.Extensions; using FictionArchive.Service.Shared.Extensions;
using FictionArchive.Service.Shared.Services.EventBus.Implementations; using FictionArchive.Service.Shared.Services.EventBus.Implementations;
using Quartz; using Quartz;
using Quartz.Impl.AdoJobStore;
namespace FictionArchive.Service.SchedulerService; namespace FictionArchive.Service.SchedulerService;
@@ -17,6 +18,12 @@ public class Program
builder.Services.AddHealthChecks(); builder.Services.AddHealthChecks();
builder.Services.AddTransient<JobManagerService>(); builder.Services.AddTransient<JobManagerService>();
#region Database
builder.Services.RegisterDbContext<SchedulerServiceDbContext>(builder.Configuration.GetConnectionString("DefaultConnection"));
#endregion
#region Event Bus #region Event Bus
builder.Services.AddRabbitMQ(opt => builder.Services.AddRabbitMQ(opt =>
@@ -30,7 +37,16 @@ public class Program
builder.Services.AddQuartz(opt => builder.Services.AddQuartz(opt =>
{ {
opt.UseMicrosoftDependencyInjectionJobFactory(); opt.UsePersistentStore(pso =>
{
pso.UsePostgres(pgsql =>
{
pgsql.ConnectionString = builder.Configuration.GetConnectionString("DefaultConnection");
pgsql.UseDriverDelegate<PostgreSQLDelegate>();
pgsql.TablePrefix = "quartz.qrtz_"; // Needed for Postgres due to the differing schema used
});
pso.UseNewtonsoftJsonSerializer();
});
}); });
builder.Services.AddQuartzHostedService(opt => builder.Services.AddQuartzHostedService(opt =>
{ {
@@ -41,6 +57,12 @@ public class Program
var app = builder.Build(); var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<SchedulerServiceDbContext>();
dbContext.UpdateDatabase();
}
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.MapHealthChecks("/healthz"); app.MapHealthChecks("/healthz");

View File

@@ -0,0 +1,19 @@
using AppAny.Quartz.EntityFrameworkCore.Migrations;
using AppAny.Quartz.EntityFrameworkCore.Migrations.PostgreSQL;
using FictionArchive.Service.Shared.Services.Database;
using Microsoft.EntityFrameworkCore;
namespace FictionArchive.Service.SchedulerService.Services;
public class SchedulerServiceDbContext : FictionArchiveDbContext
{
public SchedulerServiceDbContext(DbContextOptions options, ILogger<SchedulerServiceDbContext> logger) : base(options, logger)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.AddQuartz(builder => builder.UsePostgreSql());
base.OnModelCreating(modelBuilder);
}
}

View File

@@ -9,5 +9,8 @@
"ConnectionString": "amqp://localhost", "ConnectionString": "amqp://localhost",
"ClientIdentifier": "SchedulerService" "ClientIdentifier": "SchedulerService"
}, },
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=FictionArchive_SchedulerService;Username=postgres;password=postgres"
},
"AllowedHosts": "*" "AllowedHosts": "*"
} }