using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
///
public partial class TblAgentHistory : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AgentHistoryLevels",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
Description = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AgentHistoryLevels", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AgentHistories",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
DateCreated = table.Column(type: "timestamp with time zone", nullable: false),
Message = table.Column(type: "text", nullable: true),
HistoryLevelId = table.Column(type: "integer", nullable: false),
TemplateId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AgentHistories", x => x.Id);
table.ForeignKey(
name: "FK_AgentHistories_AgentHistoryLevels_HistoryLevelId",
column: x => x.HistoryLevelId,
principalTable: "AgentHistoryLevels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AgentHistories_Templates_TemplateId",
column: x => x.TemplateId,
principalTable: "Templates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "AgentHistoryLevels",
columns: new[] { "Id", "Description", "Name" },
values: new object[,]
{
{ 1, "Агент начал выполнять задание", "Start" },
{ 5, "Агент завершил выполнение задания", "End" }
});
migrationBuilder.CreateIndex(
name: "IX_AgentHistories_HistoryLevelId",
table: "AgentHistories",
column: "HistoryLevelId");
migrationBuilder.CreateIndex(
name: "IX_AgentHistories_TemplateId",
table: "AgentHistories",
column: "TemplateId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AgentHistories");
migrationBuilder.DropTable(
name: "AgentHistoryLevels");
}
}
}