using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Moonlight.ApiServer.Database.Migrations { /// public partial class RemovedHangfire : Migration { /// 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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "HangfireCounter", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), Key = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Value = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HangfireCounter", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireHash", columns: table => new { Key = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Field = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), Value = table.Column(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(type: "character varying(256)", maxLength: 256, nullable: false), Position = table.Column(type: "integer", nullable: false), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), Value = table.Column(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(type: "character varying(256)", maxLength: 256, nullable: false), AcquiredAt = table.Column(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(type: "character varying(256)", maxLength: 256, nullable: false), Heartbeat = table.Column(type: "timestamp with time zone", nullable: false), Queues = table.Column(type: "text", nullable: false), StartedAt = table.Column(type: "timestamp with time zone", nullable: false), WorkerCount = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HangfireServer", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireSet", columns: table => new { Key = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Value = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), Score = table.Column(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(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), StateId = table.Column(type: "bigint", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), InvocationData = table.Column(type: "text", nullable: false), StateName = table.Column(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(type: "bigint", nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Value = table.Column(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(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), JobId = table.Column(type: "bigint", nullable: false), FetchedAt = table.Column(type: "timestamp with time zone", nullable: true), Queue = table.Column(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(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), JobId = table.Column(type: "bigint", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), Data = table.Column(type: "text", nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Reason = table.Column(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"); } } }