using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
///
public partial class JobsUpdateAddJobGroupTbl : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FieldFilters_JobDetails_JobDetailsId",
schema: "job",
table: "FieldFilters");
migrationBuilder.DropTable(
name: "JobDetails",
schema: "job");
migrationBuilder.DropColumn(
name: "IsUmbrella",
schema: "job",
table: "Jobs");
migrationBuilder.RenameColumn(
name: "JobDetailsId",
schema: "job",
table: "FieldFilters",
newName: "UnitFilterId");
migrationBuilder.RenameIndex(
name: "IX_FieldFilters_JobDetailsId",
schema: "job",
table: "FieldFilters",
newName: "IX_FieldFilters_UnitFilterId");
migrationBuilder.AddColumn(
name: "JobId",
table: "Templates",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn(
name: "UnitId",
table: "Templates",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn(
name: "GroupId",
schema: "job",
table: "Jobs",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn(
name: "WorkName",
schema: "job",
table: "Jobs",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "Groups",
schema: "job",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
DateCreated = table.Column(type: "timestamp with time zone", nullable: false),
DateModified = table.Column(type: "timestamp with time zone", nullable: true),
GroupName = table.Column(type: "text", nullable: false),
IsUmbrella = table.Column(type: "boolean", nullable: true),
ShortDescription = table.Column(type: "text", nullable: false),
FullDescription = table.Column(type: "text", nullable: false),
Solution = table.Column(type: "text", nullable: false),
Duration = table.Column(type: "text", nullable: false),
ReferenceDate = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Groups", x => x.Id);
},
comment: "Таблица описания групп работ, для реализации зонтиков");
migrationBuilder.CreateTable(
name: "JobUnitFilters",
schema: "job",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
DateCreated = table.Column(type: "timestamp with time zone", nullable: false),
DateModified = table.Column(type: "timestamp with time zone", nullable: true),
UnitFilter = table.Column(type: "text", nullable: false),
JobId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobUnitFilters", x => x.Id);
table.ForeignKey(
name: "FK_JobUnitFilters_Jobs_JobId",
column: x => x.JobId,
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП");
migrationBuilder.CreateIndex(
name: "IX_Templates_JobId",
table: "Templates",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_Templates_UnitId",
table: "Templates",
column: "UnitId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_GroupId",
schema: "job",
table: "Jobs",
column: "GroupId");
migrationBuilder.CreateIndex(
name: "IX_JobUnitFilters_JobId",
schema: "job",
table: "JobUnitFilters",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_FieldFilters_JobUnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters",
column: "UnitFilterId",
principalSchema: "job",
principalTable: "JobUnitFilters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Jobs_Groups_GroupId",
schema: "job",
table: "Jobs",
column: "GroupId",
principalSchema: "job",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates",
column: "JobId",
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates",
column: "UnitId",
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FieldFilters_JobUnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters");
migrationBuilder.DropForeignKey(
name: "FK_Jobs_Groups_GroupId",
schema: "job",
table: "Jobs");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates");
migrationBuilder.DropTable(
name: "Groups",
schema: "job");
migrationBuilder.DropTable(
name: "JobUnitFilters",
schema: "job");
migrationBuilder.DropIndex(
name: "IX_Templates_JobId",
table: "Templates");
migrationBuilder.DropIndex(
name: "IX_Templates_UnitId",
table: "Templates");
migrationBuilder.DropIndex(
name: "IX_Jobs_GroupId",
schema: "job",
table: "Jobs");
migrationBuilder.DropColumn(
name: "JobId",
table: "Templates");
migrationBuilder.DropColumn(
name: "UnitId",
table: "Templates");
migrationBuilder.DropColumn(
name: "GroupId",
schema: "job",
table: "Jobs");
migrationBuilder.DropColumn(
name: "WorkName",
schema: "job",
table: "Jobs");
migrationBuilder.RenameColumn(
name: "UnitFilterId",
schema: "job",
table: "FieldFilters",
newName: "JobDetailsId");
migrationBuilder.RenameIndex(
name: "IX_FieldFilters_UnitFilterId",
schema: "job",
table: "FieldFilters",
newName: "IX_FieldFilters_JobDetailsId");
migrationBuilder.AddColumn(
name: "IsUmbrella",
schema: "job",
table: "Jobs",
type: "boolean",
nullable: true);
migrationBuilder.CreateTable(
name: "JobDetails",
schema: "job",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
JobId = table.Column(type: "uuid", nullable: false),
DateCreated = table.Column(type: "timestamp with time zone", nullable: false),
DateModified = table.Column(type: "timestamp with time zone", nullable: true),
Duration = table.Column(type: "text", nullable: false),
FullDescription = table.Column(type: "text", nullable: false),
ReferenceDate = table.Column(type: "timestamp with time zone", nullable: false),
ShortDescription = table.Column(type: "text", nullable: false),
Solution = table.Column(type: "text", nullable: false),
UnitFilter = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobDetails", x => x.Id);
table.ForeignKey(
name: "FK_JobDetails_Jobs_JobId",
column: x => x.JobId,
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП");
migrationBuilder.CreateIndex(
name: "IX_JobDetails_JobId",
schema: "job",
table: "JobDetails",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_FieldFilters_JobDetails_JobDetailsId",
schema: "job",
table: "FieldFilters",
column: "JobDetailsId",
principalSchema: "job",
principalTable: "JobDetails",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}