Files
parr_api/PARR.DAL/Migrations/20260414232025_RemoveOldTables.cs

374 lines
18 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
{
/// <inheritdoc />
public partial class RemoveOldTables : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AppInWorkInWorkGroups");
migrationBuilder.DropTable(
name: "ApplicationsInHost");
migrationBuilder.DropTable(
name: "ApplicationsInWorks");
migrationBuilder.DropTable(
name: "Hosts");
migrationBuilder.DropTable(
name: "Applications");
migrationBuilder.DropTable(
name: "EkStatuses");
migrationBuilder.DropTable(
name: "WorkGroups");
migrationBuilder.DropTable(
name: "ApplicationTypes");
migrationBuilder.DropTable(
name: "ResponseAreas");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationTypes",
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),
Description = table.Column<string>(type: "text", nullable: true),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EkStatuses",
columns: table => new
{
Code = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EkStatuses", x => x.Code);
});
migrationBuilder.CreateTable(
name: "ResponseAreas",
columns: table => new
{
Code = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ResponseAreas", x => x.Code);
});
migrationBuilder.CreateTable(
name: "Applications",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationTypeId = 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),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Applications", x => x.Id);
table.ForeignKey(
name: "FK_Applications_ApplicationTypes_ApplicationTypeId",
column: x => x.ApplicationTypeId,
principalTable: "ApplicationTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "WorkGroups",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ResponseAreaCode = table.Column<int>(type: "integer", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkGroups", x => x.Id);
table.ForeignKey(
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
column: x => x.ResponseAreaCode,
principalTable: "ResponseAreas",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApplicationsInWorks",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationId = table.Column<Guid>(type: "uuid", nullable: false),
AgentName = table.Column<string>(type: "text", nullable: true),
AgentScript = table.Column<string>(type: "text", nullable: true),
AgentTimeOutSec = table.Column<int>(type: "integer", nullable: true),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
FullDescription = table.Column<string>(type: "text", nullable: false),
IsAgent = table.Column<bool>(type: "boolean", nullable: false),
IsAutoDistributionEnabled = table.Column<bool>(type: "boolean", nullable: false),
ReferenceDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
ShortDescription = table.Column<string>(type: "text", nullable: false),
Solution = table.Column<string>(type: "text", nullable: false),
TemplateDuration = table.Column<string>(type: "text", nullable: false),
WorkId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationsInWorks", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationsInWorks_Applications_ApplicationId",
column: x => x.ApplicationId,
principalTable: "Applications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Hosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
EkStatusCode = table.Column<int>(type: "integer", nullable: false),
ResponseAreaCode = table.Column<int>(type: "integer", nullable: false),
WorkGroupId = table.Column<Guid>(type: "uuid", nullable: true),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Ek = table.Column<string>(type: "text", nullable: false),
IP = table.Column<string>(type: "text", nullable: true),
LastLogon = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Hosts", x => x.Id);
table.ForeignKey(
name: "FK_Hosts_EkStatuses_EkStatusCode",
column: x => x.EkStatusCode,
principalTable: "EkStatuses",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Hosts_ResponseAreas_ResponseAreaCode",
column: x => x.ResponseAreaCode,
principalTable: "ResponseAreas",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Hosts_WorkGroups_WorkGroupId",
column: x => x.WorkGroupId,
principalTable: "WorkGroups",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "AppInWorkInWorkGroups",
columns: table => new
{
ApplicationsInWorkId = table.Column<Guid>(type: "uuid", nullable: false),
WorkGroupId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AppInWorkInWorkGroups", x => new { x.ApplicationsInWorkId, x.WorkGroupId });
table.ForeignKey(
name: "FK_AppInWorkInWorkGroups_ApplicationsInWorks_ApplicationsInWor~",
column: x => x.ApplicationsInWorkId,
principalTable: "ApplicationsInWorks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AppInWorkInWorkGroups_WorkGroups_WorkGroupId",
column: x => x.WorkGroupId,
principalTable: "WorkGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApplicationsInHost",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationId = table.Column<Guid>(type: "uuid", nullable: false),
HostId = 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)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationsInHost", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationsInHost_Applications_ApplicationId",
column: x => x.ApplicationId,
principalTable: "Applications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ApplicationsInHost_Hosts_HostId",
column: x => x.HostId,
principalTable: "Hosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "ApplicationTypes",
columns: new[] { "Id", "DateCreated", "DateModified", "Description", "Name" },
values: new object[,]
{
{ new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ИБ", "IB" },
{ new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Сервер приложений", "APP" },
{ new Guid("4466148b-510d-4423-a58f-ce878152ff01"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Инфраструктура", "SI" },
{ new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Мониторинг", "SM" },
{ new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ЦК БС", "CKBS" },
{ new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ОС", "OS" },
{ new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "СУБД", "DB" }
});
migrationBuilder.InsertData(
table: "EkStatuses",
columns: new[] { "Code", "Name" },
values: new object[,]
{
{ 1, "1-Новый" },
{ 2, "2-Подготовка к эксплуатации" },
{ 3, "3-В эксплуатации" },
{ 4, "4-В ремонте" },
{ 5, "5-В резерве" },
{ 6, "6-Выведен из эксплуатации" },
{ 7, "7-Тестовый" },
{ 9, "9-В разработке" }
});
migrationBuilder.InsertData(
table: "ResponseAreas",
columns: new[] { "Code", "Name" },
values: new object[,]
{
{ 1, "01-ОКТ" },
{ 10, "10-КЛГ" },
{ 17, "17-МСК" },
{ 24, "24-ГОР" },
{ 28, "28-СЕВ" },
{ 51, "51-СКВ" },
{ 58, "58-ЮВСТ" },
{ 61, "61-ПРИВ" },
{ 63, "63-КБШ" },
{ 76, "76-СВРД" },
{ 80, "80-ЮУР" },
{ 83, "83-ЗСИБ" },
{ 88, "88-КРАСН" },
{ 92, "92-ВСИБ" },
{ 94, "94-ЗАБ" },
{ 96, "96-ДВС" },
{ 99, "00-ГВЦ" },
{ 100, "ОБЩЕЕ" },
{ 110, "ВП" },
{ 111, "ОСК" }
});
migrationBuilder.CreateIndex(
name: "IX_AppInWorkInWorkGroups_WorkGroupId",
table: "AppInWorkInWorkGroups",
column: "WorkGroupId");
migrationBuilder.CreateIndex(
name: "IX_Applications_ApplicationTypeId",
table: "Applications",
column: "ApplicationTypeId");
migrationBuilder.CreateIndex(
name: "IX_Applications_Name_ApplicationTypeId",
table: "Applications",
columns: new[] { "Name", "ApplicationTypeId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInHost_ApplicationId",
table: "ApplicationsInHost",
column: "ApplicationId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInHost_HostId",
table: "ApplicationsInHost",
column: "HostId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInWorks_ApplicationId",
table: "ApplicationsInWorks",
column: "ApplicationId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInWorks_WorkId_ApplicationId",
table: "ApplicationsInWorks",
columns: new[] { "WorkId", "ApplicationId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Hosts_Ek",
table: "Hosts",
column: "Ek",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Hosts_EkStatusCode",
table: "Hosts",
column: "EkStatusCode");
migrationBuilder.CreateIndex(
name: "IX_Hosts_IP",
table: "Hosts",
column: "IP");
migrationBuilder.CreateIndex(
name: "IX_Hosts_ResponseAreaCode",
table: "Hosts",
column: "ResponseAreaCode");
migrationBuilder.CreateIndex(
name: "IX_Hosts_WorkGroupId",
table: "Hosts",
column: "WorkGroupId");
migrationBuilder.CreateIndex(
name: "IX_WorkGroups_ResponseAreaCode",
table: "WorkGroups",
column: "ResponseAreaCode");
}
}
}