2023-05-19 15:15:52 +10:00
using System ;
using Microsoft.EntityFrameworkCore.Migrations ;
#nullable disable
2023-06-16 15:00:11 +10:00
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
2023-05-19 15:15:52 +10:00
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
2023-06-21 12:28:16 +10:00
public partial class DbV5 : Migration
2023-05-19 15:15:52 +10:00
{
/// <inheritdoc />
protected override void Up ( MigrationBuilder migrationBuilder )
{
2023-06-16 15:00:11 +10:00
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false ) ,
2023-06-21 12:28:16 +10:00
Description = table . Column < string > ( type : "text" , nullable : true ) ,
ApplicationTypeId = table . Column < Guid > ( type : "uuid" , nullable : true )
2023-06-16 15:00:11 +10:00
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_ApplicationTypes" , x = > x . Id ) ;
2023-06-21 12:28:16 +10:00
table . ForeignKey (
name : "FK_ApplicationTypes_ApplicationTypes_ApplicationTypeId" ,
column : x = > x . ApplicationTypeId ,
principalTable : "ApplicationTypes" ,
principalColumn : "Id" ) ;
2023-06-16 15:00:11 +10:00
} ) ;
2023-05-19 15:15:52 +10:00
migrationBuilder . CreateTable (
name : "Hosts" ,
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 ) ,
2023-06-16 15:00:11 +10:00
HostName = table . Column < string > ( type : "text" , nullable : true ) ,
2023-05-19 15:15:52 +10:00
IP = table . Column < string > ( type : "text" , nullable : false ) ,
2023-06-16 15:00:11 +10:00
RegionalEK = table . Column < string > ( type : "text" , nullable : true ) ,
LinkEK = table . Column < string > ( type : "text" , nullable : true ) ,
Status = table . Column < string > ( type : "text" , nullable : true ) ,
WorkGroup = table . Column < string > ( type : "text" , nullable : true ) ,
Responsible = table . Column < string > ( type : "text" , nullable : true )
2023-05-19 15:15:52 +10:00
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_Hosts" , x = > x . Id ) ;
} ) ;
migrationBuilder . CreateTable (
name : "JobCategories" ,
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false ) ,
Description = table . Column < string > ( type : "text" , nullable : true )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_JobCategories" , x = > x . Id ) ;
} ) ;
migrationBuilder . CreateTable (
name : "JobModes" ,
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_JobModes" , x = > x . Id ) ;
} ) ;
migrationBuilder . CreateTable (
name : "JobStatuses" ,
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false ) ,
Description = table . Column < string > ( type : "text" , nullable : true )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_JobStatuses" , x = > x . Id ) ;
} ) ;
migrationBuilder . CreateTable (
name : "JobTypes" ,
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false ) ,
Description = table . Column < string > ( type : "text" , nullable : true )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_JobTypes" , x = > x . Id ) ;
} ) ;
2023-06-16 15:00:11 +10:00
migrationBuilder . CreateTable (
name : "Applications" ,
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false ) ,
2023-06-21 12:28:16 +10:00
ApplicationTypeId = table . Column < Guid > ( type : "uuid" , nullable : false )
2023-06-16 15:00:11 +10:00
} ,
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 : "ApplicationsInHosts" ,
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 ) ,
ApplicationId = table . Column < Guid > ( type : "uuid" , nullable : false ) ,
HostId = table . Column < Guid > ( type : "uuid" , nullable : false )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_ApplicationsInHosts" , x = > x . Id ) ;
table . ForeignKey (
name : "FK_ApplicationsInHosts_Applications_ApplicationId" ,
column : x = > x . ApplicationId ,
principalTable : "Applications" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_ApplicationsInHosts_Hosts_HostId" ,
column : x = > x . HostId ,
principalTable : "Hosts" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
} ) ;
2023-05-19 15:15:52 +10:00
migrationBuilder . CreateTable (
name : "Jobs" ,
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 ) ,
Name = table . Column < string > ( type : "text" , nullable : false ) ,
2023-06-16 15:00:11 +10:00
ScriptName = table . Column < string > ( type : "text" , nullable : false ) ,
2023-05-19 15:15:52 +10:00
JobModeId = table . Column < Guid > ( type : "uuid" , nullable : false ) ,
2023-06-16 15:00:11 +10:00
JobCategoryId = table . Column < Guid > ( type : "uuid" , nullable : true ) ,
JobTypeId = table . Column < Guid > ( type : "uuid" , nullable : false ) ,
2023-06-21 12:28:16 +10:00
ApplicationId = table . Column < Guid > ( type : "uuid" , nullable : false ) ,
Frequency = table . Column < int > ( type : "integer" , nullable : false ) ,
StartAt = table . Column < DateTimeOffset > ( type : "timestamp with time zone" , nullable : false ) ,
IsEnabled = table . Column < bool > ( type : "boolean" , nullable : false )
2023-05-19 15:15:52 +10:00
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_Jobs" , x = > x . Id ) ;
2023-06-16 15:00:11 +10:00
table . ForeignKey (
name : "FK_Jobs_Applications_ApplicationId" ,
column : x = > x . ApplicationId ,
principalTable : "Applications" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
2023-05-19 15:15:52 +10:00
table . ForeignKey (
name : "FK_Jobs_JobCategories_JobCategoryId" ,
column : x = > x . JobCategoryId ,
principalTable : "JobCategories" ,
2023-06-16 15:00:11 +10:00
principalColumn : "Id" ) ;
2023-05-19 15:15:52 +10:00
table . ForeignKey (
name : "FK_Jobs_JobModes_JobModeId" ,
column : x = > x . JobModeId ,
principalTable : "JobModes" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_Jobs_JobTypes_JobTypeId" ,
column : x = > x . JobTypeId ,
principalTable : "JobTypes" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
} ) ;
migrationBuilder . CreateTable (
name : "JobJournals" ,
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 ) ,
2023-06-21 12:28:16 +10:00
DateOper = table . Column < DateTimeOffset > ( type : "timestamp with time zone" , nullable : false ) ,
2023-05-19 15:15:52 +10:00
Other = table . Column < string > ( type : "text" , nullable : true ) ,
TimeOut = table . Column < int > ( type : "integer" , nullable : true ) ,
Info = table . Column < string > ( type : "text" , nullable : true ) ,
JobStatusId = table . Column < Guid > ( type : "uuid" , nullable : false ) ,
HostId = table . Column < Guid > ( type : "uuid" , nullable : false ) ,
JobId = table . Column < Guid > ( type : "uuid" , nullable : false )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_JobJournals" , x = > x . Id ) ;
table . ForeignKey (
name : "FK_JobJournals_Hosts_HostId" ,
column : x = > x . HostId ,
principalTable : "Hosts" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_JobJournals_JobStatuses_JobStatusId" ,
column : x = > x . JobStatusId ,
principalTable : "JobStatuses" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_JobJournals_Jobs_JobId" ,
column : x = > x . JobId ,
principalTable : "Jobs" ,
principalColumn : "Id" ,
onDelete : ReferentialAction . Cascade ) ;
} ) ;
2023-06-16 15:00:11 +10:00
migrationBuilder . InsertData (
table : "ApplicationTypes" ,
2023-06-21 12:28:16 +10:00
columns : new [ ] { "Id" , "ApplicationTypeId" , "DateCreated" , "DateModified" , "Description" , "Name" } ,
2023-06-16 15:00:11 +10:00
values : new object [ , ]
{
2023-06-21 12:28:16 +10:00
{ new Guid ( "32c28386-6f13-4f7b-8508-be165b7fabdb" ) , null , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "Поле СП xml АИХ ИТ" , "APP" } ,
{ new Guid ( "7848a96c-cdee-48c1-a786-de9cb889723a" ) , null , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "Поле О С xml АИХ ИТ" , "OS" } ,
{ new Guid ( "aae2636f-b93a-42dc-873e-0764a90a0a40" ) , null , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "Поле СУБД xml АИХ ИТ" , "DB" }
2023-06-16 15:00:11 +10:00
} ) ;
migrationBuilder . InsertData (
table : "JobModes" ,
columns : new [ ] { "Id" , "DateCreated" , "DateModified" , "Name" } ,
values : new object [ , ]
{
{ new Guid ( "7516b952-510d-4aaa-971c-a14b184fc1d5" ) , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "manual" } ,
{ new Guid ( "fba4202c-5bad-49c4-b076-d1ca6e1fb158" ) , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "auto" }
} ) ;
2023-06-21 12:28:16 +10:00
migrationBuilder . InsertData (
table : "JobStatuses" ,
columns : new [ ] { "Id" , "DateCreated" , "DateModified" , "Description" , "Name" } ,
values : new object [ , ]
{
{ new Guid ( "7b945eb6-d885-4570-aff5-8866f1f75ff2" ) , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "Задание выполнено" , "finished" } ,
{ new Guid ( "edef6dc3-adad-4c77-8ad1-63bb9052355a" ) , new DateTimeOffset ( new DateTime ( 2023 , 5 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) , new TimeSpan ( 0 , 0 , 0 , 0 , 0 ) ) , null , "Задание запущено" , "started" }
} ) ;
2023-06-16 15:00:11 +10:00
migrationBuilder . CreateIndex (
name : "IX_Applications_ApplicationTypeId" ,
table : "Applications" ,
column : "ApplicationTypeId" ) ;
migrationBuilder . CreateIndex (
name : "IX_ApplicationsInHosts_ApplicationId" ,
table : "ApplicationsInHosts" ,
column : "ApplicationId" ) ;
migrationBuilder . CreateIndex (
name : "IX_ApplicationsInHosts_HostId" ,
table : "ApplicationsInHosts" ,
column : "HostId" ) ;
2023-06-21 12:28:16 +10:00
migrationBuilder . CreateIndex (
name : "IX_ApplicationTypes_ApplicationTypeId" ,
table : "ApplicationTypes" ,
column : "ApplicationTypeId" ) ;
2023-05-19 15:15:52 +10:00
migrationBuilder . CreateIndex (
name : "IX_JobJournals_HostId" ,
table : "JobJournals" ,
column : "HostId" ) ;
migrationBuilder . CreateIndex (
name : "IX_JobJournals_JobId" ,
table : "JobJournals" ,
column : "JobId" ) ;
migrationBuilder . CreateIndex (
name : "IX_JobJournals_JobStatusId" ,
table : "JobJournals" ,
column : "JobStatusId" ) ;
2023-06-16 15:00:11 +10:00
migrationBuilder . CreateIndex (
name : "IX_Jobs_ApplicationId" ,
table : "Jobs" ,
column : "ApplicationId" ) ;
2023-05-19 15:15:52 +10:00
migrationBuilder . CreateIndex (
name : "IX_Jobs_JobCategoryId" ,
table : "Jobs" ,
column : "JobCategoryId" ) ;
migrationBuilder . CreateIndex (
name : "IX_Jobs_JobModeId" ,
table : "Jobs" ,
column : "JobModeId" ) ;
migrationBuilder . CreateIndex (
name : "IX_Jobs_JobTypeId" ,
table : "Jobs" ,
column : "JobTypeId" ) ;
}
/// <inheritdoc />
protected override void Down ( MigrationBuilder migrationBuilder )
{
2023-06-16 15:00:11 +10:00
migrationBuilder . DropTable (
name : "ApplicationsInHosts" ) ;
2023-05-19 15:15:52 +10:00
migrationBuilder . DropTable (
name : "JobJournals" ) ;
migrationBuilder . DropTable (
name : "Hosts" ) ;
migrationBuilder . DropTable (
name : "JobStatuses" ) ;
migrationBuilder . DropTable (
name : "Jobs" ) ;
2023-06-16 15:00:11 +10:00
migrationBuilder . DropTable (
name : "Applications" ) ;
2023-05-19 15:15:52 +10:00
migrationBuilder . DropTable (
name : "JobCategories" ) ;
migrationBuilder . DropTable (
name : "JobModes" ) ;
migrationBuilder . DropTable (
name : "JobTypes" ) ;
2023-06-16 15:00:11 +10:00
migrationBuilder . DropTable (
name : "ApplicationTypes" ) ;
2023-05-19 15:15:52 +10:00
}
}
}