Files
Backend-Api/AccountMangement.Infrastructure.EFCore/Migrations/20240609130725_addTaskManagerToAccountContext.cs
2024-07-05 21:36:15 +03:30

182 lines
7.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AccountMangement.Infrastructure.EFCore.Migrations
{
/// <inheritdoc />
public partial class addTaskManagerToAccountContext : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "PositionId",
table: "Accounts",
type: "bigint",
maxLength: 10,
nullable: true);
migrationBuilder.CreateTable(
name: "Medias",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Path = table.Column<string>(type: "ntext", nullable: true),
Type = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medias", x => x.id);
});
migrationBuilder.CreateTable(
name: "Positions",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PositionName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
PositionValue = table.Column<int>(type: "int", maxLength: 2, nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Positions", x => x.id);
});
migrationBuilder.CreateTable(
name: "TasksManager",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
EndTaskDate = table.Column<DateTime>(type: "datetime2", nullable: false),
StartTaskDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Description = table.Column<string>(type: "ntext", nullable: true),
SenderId = table.Column<long>(type: "bigint", nullable: false),
TimeRequest = table.Column<bool>(type: "bit", nullable: false),
AcceptedTimeRequest = table.Column<int>(type: "int", nullable: false),
RequestDate = table.Column<DateTime>(type: "datetime2", nullable: true),
TimeRequestDescription = table.Column<string>(type: "ntext", nullable: true),
IsCanceledRequest = table.Column<bool>(type: "bit", nullable: false),
ContractingPartyName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
IsCancel = table.Column<bool>(type: "bit", nullable: false),
CancelDescription = table.Column<string>(type: "ntext", nullable: true),
IsDone = table.Column<bool>(type: "bit", nullable: false),
DoneDescription = table.Column<string>(type: "ntext", nullable: true),
IsActiveString = table.Column<string>(type: "nvarchar(7)", maxLength: 7, nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TasksManager", x => x.id);
});
migrationBuilder.CreateTable(
name: "Assigns",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TaskId = table.Column<long>(type: "bigint", nullable: false),
AssignerId = table.Column<long>(type: "bigint", nullable: false),
AssignedName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
AssignedId = table.Column<long>(type: "bigint", nullable: false),
AssignerPositionValue = table.Column<int>(type: "int", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Assigns", x => x.id);
table.ForeignKey(
name: "FK_Assigns_TasksManager_TaskId",
column: x => x.TaskId,
principalTable: "TasksManager",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "TasksMedias",
columns: table => new
{
TaskId = table.Column<long>(type: "bigint", nullable: false),
MediaId = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TasksMedias", x => new { x.MediaId, x.TaskId });
table.ForeignKey(
name: "FK_TasksMedias_Medias_MediaId",
column: x => x.MediaId,
principalTable: "Medias",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TasksMedias_TasksManager_TaskId",
column: x => x.TaskId,
principalTable: "TasksManager",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Accounts_PositionId",
table: "Accounts",
column: "PositionId");
migrationBuilder.CreateIndex(
name: "IX_Assigns_TaskId",
table: "Assigns",
column: "TaskId");
migrationBuilder.CreateIndex(
name: "IX_TasksMedias_TaskId",
table: "TasksMedias",
column: "TaskId");
migrationBuilder.AddForeignKey(
name: "FK_Accounts_Positions_PositionId",
table: "Accounts",
column: "PositionId",
principalTable: "Positions",
principalColumn: "id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Accounts_Positions_PositionId",
table: "Accounts");
migrationBuilder.DropTable(
name: "Assigns");
migrationBuilder.DropTable(
name: "Positions");
migrationBuilder.DropTable(
name: "TasksMedias");
migrationBuilder.DropTable(
name: "Medias");
migrationBuilder.DropTable(
name: "TasksManager");
migrationBuilder.DropIndex(
name: "IX_Accounts_PositionId",
table: "Accounts");
migrationBuilder.DropColumn(
name: "PositionId",
table: "Accounts");
}
}
}