using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Web.Migrations { /// public partial class AddCaseManagement : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ActionPlans", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ResponseId = table.Column(type: "int", nullable: false), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), ActionType = table.Column(type: "nvarchar(max)", nullable: false), Priority = table.Column(type: "nvarchar(max)", nullable: false), Status = table.Column(type: "nvarchar(max)", nullable: false), AssignedTo = table.Column(type: "nvarchar(max)", nullable: true), AssignedToEmail = table.Column(type: "nvarchar(max)", nullable: true), ScheduledDate = table.Column(type: "datetime2", nullable: true), CompletedDate = table.Column(type: "datetime2", nullable: true), CompletionNotes = table.Column(type: "nvarchar(max)", nullable: true), CreatedByName = table.Column(type: "nvarchar(max)", nullable: false), CreatedByEmail = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ResponseId = table.Column(type: "int", nullable: false), AuthorName = table.Column(type: "nvarchar(max)", nullable: false), AuthorEmail = table.Column(type: "nvarchar(max)", nullable: true), NoteText = table.Column(type: "nvarchar(max)", nullable: false), Category = table.Column(type: "nvarchar(max)", nullable: false), IsConfidential = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ResponseId = table.Column(type: "int", nullable: false), Status = table.Column(type: "int", nullable: false), ChangedByName = table.Column(type: "nvarchar(max)", nullable: true), ChangedByEmail = table.Column(type: "nvarchar(max)", nullable: true), Reason = table.Column(type: "nvarchar(max)", nullable: true), ChangedAt = table.Column(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"); } /// 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"); } } }