feat: Слияние веток. Миграции для Tasks

This commit is contained in:
Mikhail Trubnikov
2026-03-23 13:58:31 +10:00
22 changed files with 5322 additions and 140 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,172 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblTasks : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "task");
migrationBuilder.CreateTable(
name: "Statuses",
schema: "task",
columns: table => new
{
Code = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(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<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
MaxRetries = table.Column<int>(type: "integer", nullable: false),
MaxExecutionTimeMinutes = table.Column<int>(type: "integer", nullable: false),
IsSingleton = table.Column<bool>(type: "boolean", nullable: false),
RetentionDays = table.Column<int>(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<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
TypeCode = table.Column<int>(type: "integer", nullable: false),
StatusCode = table.Column<int>(type: "integer", nullable: false),
Payload = table.Column<string>(type: "text", nullable: true),
RetryCount = table.Column<int>(type: "integer", nullable: false),
ProcessedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
InitiatorIp = table.Column<string>(type: "text", nullable: true),
InitiatorParrComponentId = table.Column<int>(type: "integer", nullable: true),
InitiatorComment = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
TaskId = table.Column<Guid>(type: "uuid", nullable: false),
AttemptNumber = table.Column<int>(type: "integer", nullable: false),
ErrorMessage = table.Column<string>(type: "text", nullable: false),
StackTrace = table.Column<string>(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");
}
/// <inheritdoc />
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");
}
}
}

View File

@@ -2751,6 +2751,178 @@ namespace PARR.DAL.Migrations
b.ToTable("Subprocesses");
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskError", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AttemptNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("ErrorMessage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("StackTrace")
.HasColumnType("text");
b.Property<Guid>("TaskId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TaskId");
b.ToTable("Errors", "task", t =>
{
t.HasComment("Таблица ошибок заданий");
});
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskItem", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<string>("InitiatorComment")
.HasColumnType("text");
b.Property<string>("InitiatorIp")
.HasColumnType("text");
b.Property<int?>("InitiatorParrComponentId")
.HasColumnType("integer");
b.Property<string>("Payload")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ProcessedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("RetryCount")
.HasColumnType("integer");
b.Property<int>("StatusCode")
.HasColumnType("integer");
b.Property<int>("TypeCode")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StatusCode");
b.HasIndex("TypeCode");
b.ToTable("Tasks", "task", t =>
{
t.HasComment("Таблица заданий");
});
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskStatus", b =>
{
b.Property<int>("Code")
.HasColumnType("integer");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Code");
b.ToTable("Statuses", "task", t =>
{
t.HasComment("Таблица статусов заданий");
});
b.HasData(
new
{
Code = 0,
Description = "Ожидание",
Name = "Pending"
},
new
{
Code = 1,
Description = "В работе",
Name = "Processing"
},
new
{
Code = 2,
Description = "Выполнено успешно",
Name = "Success"
},
new
{
Code = 3,
Description = "Ошибка",
Name = "Failed"
});
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskType", b =>
{
b.Property<int>("Code")
.HasColumnType("integer");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsSingleton")
.HasColumnType("boolean");
b.Property<int>("MaxExecutionTimeMinutes")
.HasColumnType("integer");
b.Property<int>("MaxRetries")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("RetentionDays")
.HasColumnType("integer");
b.HasKey("Code");
b.ToTable("Types", "task", t =>
{
t.HasComment("Таблица типов заданий");
});
b.HasData(
new
{
Code = 0,
Description = "Формирование данных для отчетности - Загруженность",
IsSingleton = true,
MaxExecutionTimeMinutes = 30,
MaxRetries = 2,
Name = "Workload",
RetentionDays = 90
});
});
modelBuilder.Entity("PARR.DAL.Models.TaskStatus", b =>
{
b.Property<int>("Code")
@@ -3715,6 +3887,36 @@ namespace PARR.DAL.Migrations
b.Navigation("Process");
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskError", b =>
{
b.HasOne("PARR.DAL.Models.TaskModels.TaskItem", "TaskItem")
.WithMany("TaskErrors")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("TaskItem");
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskItem", b =>
{
b.HasOne("PARR.DAL.Models.TaskModels.TaskStatus", "TaskStatus")
.WithMany("Tasks")
.HasForeignKey("StatusCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.TaskModels.TaskType", "TaskType")
.WithMany("Tasks")
.HasForeignKey("TypeCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("TaskStatus");
b.Navigation("TaskType");
});
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
{
b.HasOne("PARR.DAL.Models.Job.Job", "Job")
@@ -4077,6 +4279,21 @@ namespace PARR.DAL.Migrations
b.Navigation("Tnks");
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskItem", b =>
{
b.Navigation("TaskErrors");
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskStatus", b =>
{
b.Navigation("Tasks");
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskType", b =>
{
b.Navigation("Tasks");
});
modelBuilder.Entity("PARR.DAL.Models.TaskStatus", b =>
{
b.Navigation("RobotConfigurations");