using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace PARR.DAL.Migrations { /// public partial class tblTasks : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "task"); migrationBuilder.CreateTable( name: "Statuses", schema: "task", columns: table => new { Code = table.Column(type: "integer", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Statuses", x => x.Code); }, comment: "Таблица статусов заданий"); migrationBuilder.CreateTable( name: "Types", schema: "task", columns: table => new { Code = table.Column(type: "integer", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), MaxRetries = table.Column(type: "integer", nullable: false), MaxExecutionTimeMinutes = table.Column(type: "integer", nullable: false), IsSingleton = table.Column(type: "boolean", nullable: false), RetentionDays = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Types", x => x.Code); }, comment: "Таблица типов заданий"); migrationBuilder.CreateTable( name: "Tasks", schema: "task", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false), DateModified = table.Column(type: "timestamp with time zone", nullable: true), TypeCode = table.Column(type: "integer", nullable: false), StatusCode = table.Column(type: "integer", nullable: false), Payload = table.Column(type: "text", nullable: true), RetryCount = table.Column(type: "integer", nullable: false), ProcessedAt = table.Column(type: "timestamp with time zone", nullable: true), InitiatorIp = table.Column(type: "text", nullable: true), InitiatorParrComponentId = table.Column(type: "integer", nullable: true), InitiatorComment = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); table.ForeignKey( name: "FK_Tasks_Statuses_StatusCode", column: x => x.StatusCode, principalSchema: "task", principalTable: "Statuses", principalColumn: "Code", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Tasks_Types_TypeCode", column: x => x.TypeCode, principalSchema: "task", principalTable: "Types", principalColumn: "Code", onDelete: ReferentialAction.Cascade); }, comment: "Таблица заданий"); migrationBuilder.CreateTable( name: "Errors", schema: "task", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false), TaskId = table.Column(type: "uuid", nullable: false), AttemptNumber = table.Column(type: "integer", nullable: false), ErrorMessage = table.Column(type: "text", nullable: false), StackTrace = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Errors", x => x.Id); table.ForeignKey( name: "FK_Errors_Tasks_TaskId", column: x => x.TaskId, principalSchema: "task", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }, comment: "Таблица ошибок заданий"); migrationBuilder.InsertData( schema: "task", table: "Statuses", columns: new[] { "Code", "Description", "Name" }, values: new object[,] { { 0, "Ожидание", "Pending" }, { 1, "В работе", "Processing" }, { 2, "Выполнено успешно", "Success" }, { 3, "Ошибка", "Failed" } }); migrationBuilder.InsertData( schema: "task", table: "Types", columns: new[] { "Code", "Description", "IsSingleton", "MaxExecutionTimeMinutes", "MaxRetries", "Name", "RetentionDays" }, values: new object[] { 0, "Формирование данных для отчетности - Загруженность", true, 30, 2, "Workload", 90 }); migrationBuilder.CreateIndex( name: "IX_Errors_TaskId", schema: "task", table: "Errors", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_Tasks_StatusCode", schema: "task", table: "Tasks", column: "StatusCode"); migrationBuilder.CreateIndex( name: "IX_Tasks_TypeCode", schema: "task", table: "Tasks", column: "TypeCode"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Errors", schema: "task"); migrationBuilder.DropTable( name: "Tasks", schema: "task"); migrationBuilder.DropTable( name: "Statuses", schema: "task"); migrationBuilder.DropTable( name: "Types", schema: "task"); } } }