146 lines
5.7 KiB
C#
146 lines
5.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace RLHF.Generator.Persistence.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class DurableGenerationResume : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "GenerationRunId",
|
|
schema: "dbo",
|
|
table: "TrainingItem",
|
|
type: "uniqueidentifier",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<long>(
|
|
name: "PlanOrdinal",
|
|
schema: "dbo",
|
|
table: "TrainingItem",
|
|
type: "bigint",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "RecordKey",
|
|
schema: "dbo",
|
|
table: "TrainingItem",
|
|
type: "char(64)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GenerationRun",
|
|
schema: "dbo",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Status = table.Column<string>(type: "nvarchar(16)", nullable: false),
|
|
RandomSeed = table.Column<int>(type: "int", nullable: false),
|
|
InputFingerprint = table.Column<string>(type: "char(64)", nullable: false),
|
|
ConfigurationFingerprint = table.Column<string>(type: "char(64)", nullable: false),
|
|
CurrentCategoryId = table.Column<int>(type: "int", nullable: true),
|
|
CurrentIsPositive = table.Column<bool>(type: "bit", nullable: true),
|
|
LastCommittedPlanOrdinal = table.Column<long>(type: "bigint", nullable: false),
|
|
TotalExpectedRowCount = table.Column<int>(type: "int", nullable: false),
|
|
TotalCommittedRowCount = table.Column<int>(type: "int", nullable: false),
|
|
StartedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
|
LastCheckpointAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
|
CompletedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
|
FailureType = table.Column<string>(type: "nvarchar(256)", nullable: true),
|
|
FailureMessage = table.Column<string>(type: "nvarchar(1024)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GenerationRun", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_GenerationRun_Category_CurrentCategoryId",
|
|
column: x => x.CurrentCategoryId,
|
|
principalSchema: "dbo",
|
|
principalTable: "Category",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TrainingItem_GenerationRunId_PlanOrdinal",
|
|
schema: "dbo",
|
|
table: "TrainingItem",
|
|
columns: new[] { "GenerationRunId", "PlanOrdinal" },
|
|
unique: true,
|
|
filter: "[GenerationRunId] IS NOT NULL AND [PlanOrdinal] IS NOT NULL");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TrainingItem_RecordKey",
|
|
schema: "dbo",
|
|
table: "TrainingItem",
|
|
column: "RecordKey",
|
|
unique: true,
|
|
filter: "[RecordKey] IS NOT NULL");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GenerationRun_CurrentCategoryId",
|
|
schema: "dbo",
|
|
table: "GenerationRun",
|
|
column: "CurrentCategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GenerationRun_Status",
|
|
schema: "dbo",
|
|
table: "GenerationRun",
|
|
column: "Status");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_TrainingItem_GenerationRun_GenerationRunId",
|
|
schema: "dbo",
|
|
table: "TrainingItem",
|
|
column: "GenerationRunId",
|
|
principalSchema: "dbo",
|
|
principalTable: "GenerationRun",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_TrainingItem_GenerationRun_GenerationRunId",
|
|
schema: "dbo",
|
|
table: "TrainingItem");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "GenerationRun",
|
|
schema: "dbo");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_TrainingItem_GenerationRunId_PlanOrdinal",
|
|
schema: "dbo",
|
|
table: "TrainingItem");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_TrainingItem_RecordKey",
|
|
schema: "dbo",
|
|
table: "TrainingItem");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "GenerationRunId",
|
|
schema: "dbo",
|
|
table: "TrainingItem");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "PlanOrdinal",
|
|
schema: "dbo",
|
|
table: "TrainingItem");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "RecordKey",
|
|
schema: "dbo",
|
|
table: "TrainingItem");
|
|
}
|
|
}
|
|
}
|