146 lines
6.7 KiB
C#
146 lines
6.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Web.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddCaseManagement : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ActionPlans",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ResponseId = table.Column<int>(type: "int", nullable: false),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ActionType = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Priority = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Status = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
AssignedTo = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
AssignedToEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ScheduledDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CompletedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CompletionNotes = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
CreatedByName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CreatedByEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ActionPlans", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ActionPlans_Responses_ResponseId",
|
|
column: x => x.ResponseId,
|
|
principalTable: "Responses",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CaseNotes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ResponseId = table.Column<int>(type: "int", nullable: false),
|
|
AuthorName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
AuthorEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
NoteText = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Category = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
IsConfidential = table.Column<bool>(type: "bit", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CaseNotes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CaseNotes_Responses_ResponseId",
|
|
column: x => x.ResponseId,
|
|
principalTable: "Responses",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CaseStatusEntries",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ResponseId = table.Column<int>(type: "int", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
ChangedByName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ChangedByEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
Reason = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ChangedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CaseStatusEntries", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CaseStatusEntries_Responses_ResponseId",
|
|
column: x => x.ResponseId,
|
|
principalTable: "Responses",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ResponseAnswers_AnswerId",
|
|
table: "ResponseAnswers",
|
|
column: "AnswerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ActionPlans_ResponseId",
|
|
table: "ActionPlans",
|
|
column: "ResponseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CaseNotes_ResponseId",
|
|
table: "CaseNotes",
|
|
column: "ResponseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CaseStatusEntries_ResponseId",
|
|
table: "CaseStatusEntries",
|
|
column: "ResponseId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ResponseAnswers_Answers_AnswerId",
|
|
table: "ResponseAnswers",
|
|
column: "AnswerId",
|
|
principalTable: "Answers",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ResponseAnswers_Answers_AnswerId",
|
|
table: "ResponseAnswers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ActionPlans");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CaseNotes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CaseStatusEntries");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_ResponseAnswers_AnswerId",
|
|
table: "ResponseAnswers");
|
|
}
|
|
}
|
|
}
|