Removed hangfire. Added TickerQ

This commit is contained in:
2025-08-19 22:53:12 +02:00
parent 60178dc54b
commit ab92edb008
20 changed files with 1267 additions and 487 deletions

View File

@@ -1,5 +1,4 @@
using Hangfire.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using MoonCore.Extended.SingleDb;
using Moonlight.ApiServer.Configuration;
using Moonlight.ApiServer.Database.Entities;
@@ -30,7 +29,6 @@ public class CoreDataContext : DatabaseContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.OnHangfireModelCreating();
modelBuilder.Ignore<ApplicationTheme>();
modelBuilder.Entity<Theme>()

View File

@@ -0,0 +1,260 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Moonlight.ApiServer.Database;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Moonlight.ApiServer.Database.Migrations
{
[DbContext(typeof(CoreDataContext))]
[Migration("20250819195904_RemovedHangfire")]
partial class RemovedHangfire
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.PrimitiveCollection<string[]>("Permissions")
.IsRequired()
.HasColumnType("text[]");
b.HasKey("Id");
b.ToTable("Core_ApiKeys", (string)null);
});
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.Theme", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Author")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DonateUrl")
.HasColumnType("text");
b.Property<bool>("IsEnabled")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdateUrl")
.HasColumnType("text");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Core_Themes", (string)null);
});
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.PrimitiveCollection<string[]>("Permissions")
.IsRequired()
.HasColumnType("text[]");
b.Property<DateTimeOffset>("TokenValidTimestamp")
.HasColumnType("timestamp with time zone");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Core_Users", (string)null);
});
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.Theme", b =>
{
b.OwnsOne("Moonlight.ApiServer.Models.ApplicationTheme", "Content", b1 =>
{
b1.Property<int>("ThemeId")
.HasColumnType("integer");
b1.Property<float>("Border")
.HasColumnType("real");
b1.Property<string>("ColorAccent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorAccentContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBackground")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBase100")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBase150")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBase200")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBase250")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBase300")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorBaseContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorError")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorErrorContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorInfo")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorInfoContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorNeutral")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorNeutralContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorPrimary")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorPrimaryContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorSecondary")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorSecondaryContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorSuccess")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorSuccessContent")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorWarning")
.IsRequired()
.HasColumnType("text");
b1.Property<string>("ColorWarningContent")
.IsRequired()
.HasColumnType("text");
b1.Property<int>("Depth")
.HasColumnType("integer");
b1.Property<int>("Noise")
.HasColumnType("integer");
b1.Property<float>("RadiusBox")
.HasColumnType("real");
b1.Property<float>("RadiusField")
.HasColumnType("real");
b1.Property<float>("RadiusSelector")
.HasColumnType("real");
b1.Property<float>("SizeField")
.HasColumnType("real");
b1.Property<float>("SizeSelector")
.HasColumnType("real");
b1.HasKey("ThemeId");
b1.ToTable("Core_Themes");
b1.ToJson("Content");
b1.WithOwner()
.HasForeignKey("ThemeId");
});
b.Navigation("Content")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,290 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Moonlight.ApiServer.Database.Migrations
{
/// <inheritdoc />
public partial class RemovedHangfire : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_HangfireJob_HangfireState_StateId",
table: "HangfireJob");
migrationBuilder.DropTable(
name: "HangfireCounter");
migrationBuilder.DropTable(
name: "HangfireHash");
migrationBuilder.DropTable(
name: "HangfireJobParameter");
migrationBuilder.DropTable(
name: "HangfireList");
migrationBuilder.DropTable(
name: "HangfireLock");
migrationBuilder.DropTable(
name: "HangfireQueuedJob");
migrationBuilder.DropTable(
name: "HangfireServer");
migrationBuilder.DropTable(
name: "HangfireSet");
migrationBuilder.DropTable(
name: "HangfireState");
migrationBuilder.DropTable(
name: "HangfireJob");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "HangfireCounter",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ExpireAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Key = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Value = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireCounter", x => x.Id);
});
migrationBuilder.CreateTable(
name: "HangfireHash",
columns: table => new
{
Key = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Field = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
ExpireAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireHash", x => new { x.Key, x.Field });
});
migrationBuilder.CreateTable(
name: "HangfireList",
columns: table => new
{
Key = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
ExpireAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireList", x => new { x.Key, x.Position });
});
migrationBuilder.CreateTable(
name: "HangfireLock",
columns: table => new
{
Id = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
AcquiredAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireLock", x => x.Id);
});
migrationBuilder.CreateTable(
name: "HangfireServer",
columns: table => new
{
Id = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Heartbeat = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Queues = table.Column<string>(type: "text", nullable: false),
StartedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
WorkerCount = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireServer", x => x.Id);
});
migrationBuilder.CreateTable(
name: "HangfireSet",
columns: table => new
{
Key = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Value = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
ExpireAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Score = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireSet", x => new { x.Key, x.Value });
});
migrationBuilder.CreateTable(
name: "HangfireJob",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StateId = table.Column<long>(type: "bigint", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ExpireAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
InvocationData = table.Column<string>(type: "text", nullable: false),
StateName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireJob", x => x.Id);
});
migrationBuilder.CreateTable(
name: "HangfireJobParameter",
columns: table => new
{
JobId = table.Column<long>(type: "bigint", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireJobParameter", x => new { x.JobId, x.Name });
table.ForeignKey(
name: "FK_HangfireJobParameter_HangfireJob_JobId",
column: x => x.JobId,
principalTable: "HangfireJob",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "HangfireQueuedJob",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
JobId = table.Column<long>(type: "bigint", nullable: false),
FetchedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Queue = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireQueuedJob", x => x.Id);
table.ForeignKey(
name: "FK_HangfireQueuedJob_HangfireJob_JobId",
column: x => x.JobId,
principalTable: "HangfireJob",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "HangfireState",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
JobId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Data = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Reason = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_HangfireState", x => x.Id);
table.ForeignKey(
name: "FK_HangfireState_HangfireJob_JobId",
column: x => x.JobId,
principalTable: "HangfireJob",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_HangfireCounter_ExpireAt",
table: "HangfireCounter",
column: "ExpireAt");
migrationBuilder.CreateIndex(
name: "IX_HangfireCounter_Key_Value",
table: "HangfireCounter",
columns: new[] { "Key", "Value" });
migrationBuilder.CreateIndex(
name: "IX_HangfireHash_ExpireAt",
table: "HangfireHash",
column: "ExpireAt");
migrationBuilder.CreateIndex(
name: "IX_HangfireJob_ExpireAt",
table: "HangfireJob",
column: "ExpireAt");
migrationBuilder.CreateIndex(
name: "IX_HangfireJob_StateId",
table: "HangfireJob",
column: "StateId");
migrationBuilder.CreateIndex(
name: "IX_HangfireJob_StateName",
table: "HangfireJob",
column: "StateName");
migrationBuilder.CreateIndex(
name: "IX_HangfireList_ExpireAt",
table: "HangfireList",
column: "ExpireAt");
migrationBuilder.CreateIndex(
name: "IX_HangfireQueuedJob_JobId",
table: "HangfireQueuedJob",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_HangfireQueuedJob_Queue_FetchedAt",
table: "HangfireQueuedJob",
columns: new[] { "Queue", "FetchedAt" });
migrationBuilder.CreateIndex(
name: "IX_HangfireServer_Heartbeat",
table: "HangfireServer",
column: "Heartbeat");
migrationBuilder.CreateIndex(
name: "IX_HangfireSet_ExpireAt",
table: "HangfireSet",
column: "ExpireAt");
migrationBuilder.CreateIndex(
name: "IX_HangfireSet_Key_Score",
table: "HangfireSet",
columns: new[] { "Key", "Score" });
migrationBuilder.CreateIndex(
name: "IX_HangfireState_JobId",
table: "HangfireState",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_HangfireJob_HangfireState_StateId",
table: "HangfireJob",
column: "StateId",
principalTable: "HangfireState",
principalColumn: "Id");
}
}
}

View File

@@ -0,0 +1,222 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Moonlight.ApiServer.Database;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Moonlight.ApiServer.Database.Migrations
{
[DbContext(typeof(TickerDataContext))]
[Migration("20250819200221_AddedTickerQ")]
partial class AddedTickerQ
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.CronTickerEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("Expression")
.HasColumnType("text");
b.Property<string>("Function")
.HasColumnType("text");
b.Property<string>("InitIdentifier")
.HasColumnType("text");
b.Property<byte[]>("Request")
.HasColumnType("bytea");
b.Property<int>("Retries")
.HasColumnType("integer");
b.PrimitiveCollection<int[]>("RetryIntervals")
.HasColumnType("integer[]");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Expression")
.HasDatabaseName("IX_CronTickers_Expression");
b.ToTable("CronTickers", "ticker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.CronTickerOccurrenceEntity<TickerQ.EntityFrameworkCore.Entities.CronTickerEntity>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CronTickerId")
.HasColumnType("uuid");
b.Property<long>("ElapsedTime")
.HasColumnType("bigint");
b.Property<string>("Exception")
.HasColumnType("text");
b.Property<DateTime?>("ExecutedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("ExecutionTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("LockHolder")
.HasColumnType("text");
b.Property<DateTime?>("LockedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("RetryCount")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CronTickerId")
.HasDatabaseName("IX_CronTickerOccurrence_CronTickerId");
b.HasIndex("ExecutionTime")
.HasDatabaseName("IX_CronTickerOccurrence_ExecutionTime");
b.HasIndex("CronTickerId", "ExecutionTime")
.IsUnique()
.HasDatabaseName("UQ_CronTickerId_ExecutionTime");
b.HasIndex("Status", "ExecutionTime")
.HasDatabaseName("IX_CronTickerOccurrence_Status_ExecutionTime");
b.ToTable("CronTickerOccurrences", "ticker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("BatchParent")
.HasColumnType("uuid");
b.Property<int?>("BatchRunCondition")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<long>("ElapsedTime")
.HasColumnType("bigint");
b.Property<string>("Exception")
.HasColumnType("text");
b.Property<DateTime?>("ExecutedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("ExecutionTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Function")
.HasColumnType("text");
b.Property<string>("InitIdentifier")
.HasColumnType("text");
b.Property<string>("LockHolder")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<DateTime?>("LockedAt")
.HasColumnType("timestamp with time zone");
b.Property<byte[]>("Request")
.HasColumnType("bytea");
b.Property<int>("Retries")
.HasColumnType("integer");
b.Property<int>("RetryCount")
.HasColumnType("integer");
b.PrimitiveCollection<int[]>("RetryIntervals")
.HasColumnType("integer[]");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BatchParent");
b.HasIndex("ExecutionTime")
.HasDatabaseName("IX_TimeTicker_ExecutionTime");
b.HasIndex("Status", "ExecutionTime")
.HasDatabaseName("IX_TimeTicker_Status_ExecutionTime");
b.ToTable("TimeTickers", "ticker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.CronTickerOccurrenceEntity<TickerQ.EntityFrameworkCore.Entities.CronTickerEntity>", b =>
{
b.HasOne("TickerQ.EntityFrameworkCore.Entities.CronTickerEntity", "CronTicker")
.WithMany()
.HasForeignKey("CronTickerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CronTicker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", b =>
{
b.HasOne("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", "ParentJob")
.WithMany("ChildJobs")
.HasForeignKey("BatchParent")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("ParentJob");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", b =>
{
b.Navigation("ChildJobs");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,169 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Moonlight.ApiServer.Database.Migrations
{
/// <inheritdoc />
public partial class AddedTickerQ : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "ticker");
migrationBuilder.CreateTable(
name: "CronTickers",
schema: "ticker",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Expression = table.Column<string>(type: "text", nullable: true),
Request = table.Column<byte[]>(type: "bytea", nullable: true),
Retries = table.Column<int>(type: "integer", nullable: false),
RetryIntervals = table.Column<int[]>(type: "integer[]", nullable: true),
Function = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
InitIdentifier = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CronTickers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TimeTickers",
schema: "ticker",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
LockHolder = table.Column<string>(type: "text", nullable: true),
Request = table.Column<byte[]>(type: "bytea", nullable: true),
ExecutionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LockedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
ExecutedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Exception = table.Column<string>(type: "text", nullable: true),
ElapsedTime = table.Column<long>(type: "bigint", nullable: false),
Retries = table.Column<int>(type: "integer", nullable: false),
RetryCount = table.Column<int>(type: "integer", nullable: false),
RetryIntervals = table.Column<int[]>(type: "integer[]", nullable: true),
BatchParent = table.Column<Guid>(type: "uuid", nullable: true),
BatchRunCondition = table.Column<int>(type: "integer", nullable: true),
Function = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
InitIdentifier = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TimeTickers", x => x.Id);
table.ForeignKey(
name: "FK_TimeTickers_TimeTickers_BatchParent",
column: x => x.BatchParent,
principalSchema: "ticker",
principalTable: "TimeTickers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CronTickerOccurrences",
schema: "ticker",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
LockHolder = table.Column<string>(type: "text", nullable: true),
ExecutionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
CronTickerId = table.Column<Guid>(type: "uuid", nullable: false),
LockedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
ExecutedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Exception = table.Column<string>(type: "text", nullable: true),
ElapsedTime = table.Column<long>(type: "bigint", nullable: false),
RetryCount = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CronTickerOccurrences", x => x.Id);
table.ForeignKey(
name: "FK_CronTickerOccurrences_CronTickers_CronTickerId",
column: x => x.CronTickerId,
principalSchema: "ticker",
principalTable: "CronTickers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CronTickerOccurrence_CronTickerId",
schema: "ticker",
table: "CronTickerOccurrences",
column: "CronTickerId");
migrationBuilder.CreateIndex(
name: "IX_CronTickerOccurrence_ExecutionTime",
schema: "ticker",
table: "CronTickerOccurrences",
column: "ExecutionTime");
migrationBuilder.CreateIndex(
name: "IX_CronTickerOccurrence_Status_ExecutionTime",
schema: "ticker",
table: "CronTickerOccurrences",
columns: new[] { "Status", "ExecutionTime" });
migrationBuilder.CreateIndex(
name: "UQ_CronTickerId_ExecutionTime",
schema: "ticker",
table: "CronTickerOccurrences",
columns: new[] { "CronTickerId", "ExecutionTime" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CronTickers_Expression",
schema: "ticker",
table: "CronTickers",
column: "Expression");
migrationBuilder.CreateIndex(
name: "IX_TimeTicker_ExecutionTime",
schema: "ticker",
table: "TimeTickers",
column: "ExecutionTime");
migrationBuilder.CreateIndex(
name: "IX_TimeTicker_Status_ExecutionTime",
schema: "ticker",
table: "TimeTickers",
columns: new[] { "Status", "ExecutionTime" });
migrationBuilder.CreateIndex(
name: "IX_TimeTickers_BatchParent",
schema: "ticker",
table: "TimeTickers",
column: "BatchParent");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CronTickerOccurrences",
schema: "ticker");
migrationBuilder.DropTable(
name: "TimeTickers",
schema: "ticker");
migrationBuilder.DropTable(
name: "CronTickers",
schema: "ticker");
}
}
}

View File

@@ -22,259 +22,6 @@ namespace Moonlight.ApiServer.Database.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireCounter", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime?>("ExpireAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<long>("Value")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ExpireAt");
b.HasIndex("Key", "Value");
b.ToTable("HangfireCounter");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireHash", b =>
{
b.Property<string>("Key")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("Field")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("ExpireAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("Key", "Field");
b.HasIndex("ExpireAt");
b.ToTable("HangfireHash");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("ExpireAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("InvocationData")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("StateId")
.HasColumnType("bigint");
b.Property<string>("StateName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("ExpireAt");
b.HasIndex("StateId");
b.HasIndex("StateName");
b.ToTable("HangfireJob");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
{
b.Property<long>("JobId")
.HasColumnType("bigint");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("JobId", "Name");
b.ToTable("HangfireJobParameter");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireList", b =>
{
b.Property<string>("Key")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<DateTime?>("ExpireAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("Key", "Position");
b.HasIndex("ExpireAt");
b.ToTable("HangfireList");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireLock", b =>
{
b.Property<string>("Id")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime>("AcquiredAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("HangfireLock");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime?>("FetchedAt")
.IsConcurrencyToken()
.HasColumnType("timestamp with time zone");
b.Property<long>("JobId")
.HasColumnType("bigint");
b.Property<string>("Queue")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("JobId");
b.HasIndex("Queue", "FetchedAt");
b.ToTable("HangfireQueuedJob");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireServer", b =>
{
b.Property<string>("Id")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime>("Heartbeat")
.HasColumnType("timestamp with time zone");
b.Property<string>("Queues")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("WorkerCount")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Heartbeat");
b.ToTable("HangfireServer");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireSet", b =>
{
b.Property<string>("Key")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("Value")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("ExpireAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Score")
.HasColumnType("double precision");
b.HasKey("Key", "Value");
b.HasIndex("ExpireAt");
b.HasIndex("Key", "Score");
b.ToTable("HangfireSet");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<long>("JobId")
.HasColumnType("bigint");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("Reason")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("JobId");
b.ToTable("HangfireState");
});
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
{
b.Property<int>("Id")
@@ -368,48 +115,6 @@ namespace Moonlight.ApiServer.Database.Migrations
b.ToTable("Core_Users", (string)null);
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
{
b.HasOne("Hangfire.EntityFrameworkCore.HangfireState", "State")
.WithMany()
.HasForeignKey("StateId");
b.Navigation("State");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
{
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
.WithMany("Parameters")
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Job");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
{
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
.WithMany("QueuedJobs")
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Job");
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
{
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
.WithMany("States")
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Job");
});
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.Theme", b =>
{
b.OwnsOne("Moonlight.ApiServer.Models.ApplicationTheme", "Content", b1 =>
@@ -512,11 +217,11 @@ namespace Moonlight.ApiServer.Database.Migrations
.IsRequired()
.HasColumnType("text");
b1.Property<float>("Depth")
.HasColumnType("real");
b1.Property<int>("Depth")
.HasColumnType("integer");
b1.Property<float>("Noise")
.HasColumnType("real");
b1.Property<int>("Noise")
.HasColumnType("integer");
b1.Property<float>("RadiusBox")
.HasColumnType("real");
@@ -546,15 +251,6 @@ namespace Moonlight.ApiServer.Database.Migrations
b.Navigation("Content")
.IsRequired();
});
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
{
b.Navigation("Parameters");
b.Navigation("QueuedJobs");
b.Navigation("States");
});
#pragma warning restore 612, 618
}
}

View File

@@ -0,0 +1,219 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Moonlight.ApiServer.Database;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Moonlight.ApiServer.Database.Migrations
{
[DbContext(typeof(TickerDataContext))]
partial class TickerDataContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.CronTickerEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("Expression")
.HasColumnType("text");
b.Property<string>("Function")
.HasColumnType("text");
b.Property<string>("InitIdentifier")
.HasColumnType("text");
b.Property<byte[]>("Request")
.HasColumnType("bytea");
b.Property<int>("Retries")
.HasColumnType("integer");
b.PrimitiveCollection<int[]>("RetryIntervals")
.HasColumnType("integer[]");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Expression")
.HasDatabaseName("IX_CronTickers_Expression");
b.ToTable("CronTickers", "ticker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.CronTickerOccurrenceEntity<TickerQ.EntityFrameworkCore.Entities.CronTickerEntity>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CronTickerId")
.HasColumnType("uuid");
b.Property<long>("ElapsedTime")
.HasColumnType("bigint");
b.Property<string>("Exception")
.HasColumnType("text");
b.Property<DateTime?>("ExecutedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("ExecutionTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("LockHolder")
.HasColumnType("text");
b.Property<DateTime?>("LockedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("RetryCount")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CronTickerId")
.HasDatabaseName("IX_CronTickerOccurrence_CronTickerId");
b.HasIndex("ExecutionTime")
.HasDatabaseName("IX_CronTickerOccurrence_ExecutionTime");
b.HasIndex("CronTickerId", "ExecutionTime")
.IsUnique()
.HasDatabaseName("UQ_CronTickerId_ExecutionTime");
b.HasIndex("Status", "ExecutionTime")
.HasDatabaseName("IX_CronTickerOccurrence_Status_ExecutionTime");
b.ToTable("CronTickerOccurrences", "ticker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("BatchParent")
.HasColumnType("uuid");
b.Property<int?>("BatchRunCondition")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<long>("ElapsedTime")
.HasColumnType("bigint");
b.Property<string>("Exception")
.HasColumnType("text");
b.Property<DateTime?>("ExecutedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("ExecutionTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Function")
.HasColumnType("text");
b.Property<string>("InitIdentifier")
.HasColumnType("text");
b.Property<string>("LockHolder")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<DateTime?>("LockedAt")
.HasColumnType("timestamp with time zone");
b.Property<byte[]>("Request")
.HasColumnType("bytea");
b.Property<int>("Retries")
.HasColumnType("integer");
b.Property<int>("RetryCount")
.HasColumnType("integer");
b.PrimitiveCollection<int[]>("RetryIntervals")
.HasColumnType("integer[]");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BatchParent");
b.HasIndex("ExecutionTime")
.HasDatabaseName("IX_TimeTicker_ExecutionTime");
b.HasIndex("Status", "ExecutionTime")
.HasDatabaseName("IX_TimeTicker_Status_ExecutionTime");
b.ToTable("TimeTickers", "ticker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.CronTickerOccurrenceEntity<TickerQ.EntityFrameworkCore.Entities.CronTickerEntity>", b =>
{
b.HasOne("TickerQ.EntityFrameworkCore.Entities.CronTickerEntity", "CronTicker")
.WithMany()
.HasForeignKey("CronTickerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CronTicker");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", b =>
{
b.HasOne("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", "ParentJob")
.WithMany("ChildJobs")
.HasForeignKey("BatchParent")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("ParentJob");
});
modelBuilder.Entity("TickerQ.EntityFrameworkCore.Entities.TimeTickerEntity", b =>
{
b.Navigation("ChildJobs");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using MoonCore.Extended.SingleDb;
using Moonlight.ApiServer.Configuration;
using TickerQ.EntityFrameworkCore.Configurations;
namespace Moonlight.ApiServer.Database;
public class TickerDataContext : DatabaseContext
{
public override string Prefix => "Ticker";
public TickerDataContext(AppConfiguration configuration)
{
Options = new()
{
Host = configuration.Database.Host,
Port = configuration.Database.Port,
Username = configuration.Database.Username,
Password = configuration.Database.Password,
Database = configuration.Database.Database
};
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Apply TickerQ entity configurations explicitly
modelBuilder.ApplyConfiguration(new TimeTickerConfigurations());
modelBuilder.ApplyConfiguration(new CronTickerConfigurations());
modelBuilder.ApplyConfiguration(new CronTickerOccurrenceConfigurations());
}
}