using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Moonlight.ApiServer.Database.Migrations { /// public partial class RecreatedMigrationsForChangeOfSchema : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "core"); migrationBuilder.CreateTable( name: "ApiKeys", schema: "core", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Description = table.Column(type: "text", nullable: false), Permissions = table.Column(type: "text[]", nullable: false), ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ApiKeys", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireCounter", schema: "core", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Key = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Value = table.Column(type: "bigint", nullable: false), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_HangfireCounter", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireHash", schema: "core", 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), Value = table.Column(type: "text", nullable: true), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_HangfireHash", x => new { x.Key, x.Field }); }); migrationBuilder.CreateTable( name: "HangfireList", schema: "core", columns: table => new { Key = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Position = table.Column(type: "integer", nullable: false), Value = table.Column(type: "text", nullable: true), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_HangfireList", x => new { x.Key, x.Position }); }); migrationBuilder.CreateTable( name: "HangfireLock", schema: "core", 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", schema: "core", columns: table => new { Id = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), StartedAt = table.Column(type: "timestamp with time zone", nullable: false), Heartbeat = table.Column(type: "timestamp with time zone", nullable: false), WorkerCount = table.Column(type: "integer", nullable: false), Queues = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HangfireServer", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireSet", schema: "core", 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), Score = table.Column(type: "double precision", nullable: false), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_HangfireSet", x => new { x.Key, x.Value }); }); migrationBuilder.CreateTable( name: "Themes", schema: "core", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), IsEnabled = table.Column(type: "boolean", nullable: false), Name = table.Column(type: "text", nullable: false), Author = table.Column(type: "text", nullable: false), Version = table.Column(type: "text", nullable: false), UpdateUrl = table.Column(type: "text", nullable: true), DonateUrl = table.Column(type: "text", nullable: true), Content = table.Column(type: "jsonb", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Themes", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", schema: "core", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Username = table.Column(type: "text", nullable: false), Email = table.Column(type: "text", nullable: false), Password = table.Column(type: "text", nullable: false), TokenValidTimestamp = table.Column(type: "timestamp with time zone", nullable: false), Permissions = table.Column(type: "text[]", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireJob", schema: "core", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), StateId = table.Column(type: "bigint", nullable: true), StateName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), InvocationData = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HangfireJob", x => x.Id); }); migrationBuilder.CreateTable( name: "HangfireJobParameter", schema: "core", 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, principalSchema: "core", principalTable: "HangfireJob", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "HangfireQueuedJob", schema: "core", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), JobId = table.Column(type: "bigint", nullable: false), Queue = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), FetchedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_HangfireQueuedJob", x => x.Id); table.ForeignKey( name: "FK_HangfireQueuedJob_HangfireJob_JobId", column: x => x.JobId, principalSchema: "core", principalTable: "HangfireJob", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "HangfireState", schema: "core", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), JobId = table.Column(type: "bigint", nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Reason = table.Column(type: "text", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), Data = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HangfireState", x => x.Id); table.ForeignKey( name: "FK_HangfireState_HangfireJob_JobId", column: x => x.JobId, principalSchema: "core", principalTable: "HangfireJob", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_HangfireCounter_ExpireAt", schema: "core", table: "HangfireCounter", column: "ExpireAt"); migrationBuilder.CreateIndex( name: "IX_HangfireCounter_Key_Value", schema: "core", table: "HangfireCounter", columns: new[] { "Key", "Value" }); migrationBuilder.CreateIndex( name: "IX_HangfireHash_ExpireAt", schema: "core", table: "HangfireHash", column: "ExpireAt"); migrationBuilder.CreateIndex( name: "IX_HangfireJob_ExpireAt", schema: "core", table: "HangfireJob", column: "ExpireAt"); migrationBuilder.CreateIndex( name: "IX_HangfireJob_StateId", schema: "core", table: "HangfireJob", column: "StateId"); migrationBuilder.CreateIndex( name: "IX_HangfireJob_StateName", schema: "core", table: "HangfireJob", column: "StateName"); migrationBuilder.CreateIndex( name: "IX_HangfireList_ExpireAt", schema: "core", table: "HangfireList", column: "ExpireAt"); migrationBuilder.CreateIndex( name: "IX_HangfireQueuedJob_JobId", schema: "core", table: "HangfireQueuedJob", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_HangfireQueuedJob_Queue_FetchedAt", schema: "core", table: "HangfireQueuedJob", columns: new[] { "Queue", "FetchedAt" }); migrationBuilder.CreateIndex( name: "IX_HangfireServer_Heartbeat", schema: "core", table: "HangfireServer", column: "Heartbeat"); migrationBuilder.CreateIndex( name: "IX_HangfireSet_ExpireAt", schema: "core", table: "HangfireSet", column: "ExpireAt"); migrationBuilder.CreateIndex( name: "IX_HangfireSet_Key_Score", schema: "core", table: "HangfireSet", columns: new[] { "Key", "Score" }); migrationBuilder.CreateIndex( name: "IX_HangfireState_JobId", schema: "core", table: "HangfireState", column: "JobId"); migrationBuilder.AddForeignKey( name: "FK_HangfireJob_HangfireState_StateId", schema: "core", table: "HangfireJob", column: "StateId", principalSchema: "core", principalTable: "HangfireState", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_HangfireJob_HangfireState_StateId", schema: "core", table: "HangfireJob"); migrationBuilder.DropTable( name: "ApiKeys", schema: "core"); migrationBuilder.DropTable( name: "HangfireCounter", schema: "core"); migrationBuilder.DropTable( name: "HangfireHash", schema: "core"); migrationBuilder.DropTable( name: "HangfireJobParameter", schema: "core"); migrationBuilder.DropTable( name: "HangfireList", schema: "core"); migrationBuilder.DropTable( name: "HangfireLock", schema: "core"); migrationBuilder.DropTable( name: "HangfireQueuedJob", schema: "core"); migrationBuilder.DropTable( name: "HangfireServer", schema: "core"); migrationBuilder.DropTable( name: "HangfireSet", schema: "core"); migrationBuilder.DropTable( name: "Themes", schema: "core"); migrationBuilder.DropTable( name: "Users", schema: "core"); migrationBuilder.DropTable( name: "HangfireState", schema: "core"); migrationBuilder.DropTable( name: "HangfireJob", schema: "core"); } } }