study-lib-backend/Migrations/20201204185921_SubModelsUpdate2.cs

224 lines
7.2 KiB
C#
Raw Normal View History

2020-12-12 14:47:20 +01:00
using Microsoft.EntityFrameworkCore.Migrations;
namespace StudyLib.Migrations
{
public partial class SubModelsUpdate2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Assignment_Subjects_SubjectID",
table: "Assignment");
migrationBuilder.DropForeignKey(
name: "FK_Comment_Subjects_SubjectID",
table: "Comment");
migrationBuilder.DropForeignKey(
name: "FK_MinorExam_Subjects_SubjectID",
table: "MinorExam");
migrationBuilder.DropPrimaryKey(
name: "PK_MinorExam",
table: "MinorExam");
migrationBuilder.DropPrimaryKey(
name: "PK_Comment",
table: "Comment");
migrationBuilder.DropPrimaryKey(
name: "PK_Assignment",
table: "Assignment");
migrationBuilder.RenameTable(
name: "MinorExam",
newName: "MinorExams");
migrationBuilder.RenameTable(
name: "Comment",
newName: "Comments");
migrationBuilder.RenameTable(
name: "Assignment",
newName: "Assignments");
migrationBuilder.RenameColumn(
name: "SubjectID",
table: "MinorExams",
newName: "SubjectId");
migrationBuilder.RenameIndex(
name: "IX_MinorExam_SubjectID",
table: "MinorExams",
newName: "IX_MinorExams_SubjectId");
migrationBuilder.RenameColumn(
name: "SubjectID",
table: "Comments",
newName: "SubjectId");
migrationBuilder.RenameIndex(
name: "IX_Comment_SubjectID",
table: "Comments",
newName: "IX_Comments_SubjectId");
migrationBuilder.RenameColumn(
name: "SubjectID",
table: "Assignments",
newName: "SubjectId");
migrationBuilder.RenameIndex(
name: "IX_Assignment_SubjectID",
table: "Assignments",
newName: "IX_Assignments_SubjectId");
migrationBuilder.AddPrimaryKey(
name: "PK_MinorExams",
table: "MinorExams",
column: "ID");
migrationBuilder.AddPrimaryKey(
name: "PK_Comments",
table: "Comments",
column: "ID");
migrationBuilder.AddPrimaryKey(
name: "PK_Assignments",
table: "Assignments",
column: "ID");
migrationBuilder.AddForeignKey(
name: "FK_Assignments_Subjects_SubjectId",
table: "Assignments",
column: "SubjectId",
principalTable: "Subjects",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Comments_Subjects_SubjectId",
table: "Comments",
column: "SubjectId",
principalTable: "Subjects",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_MinorExams_Subjects_SubjectId",
table: "MinorExams",
column: "SubjectId",
principalTable: "Subjects",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Assignments_Subjects_SubjectId",
table: "Assignments");
migrationBuilder.DropForeignKey(
name: "FK_Comments_Subjects_SubjectId",
table: "Comments");
migrationBuilder.DropForeignKey(
name: "FK_MinorExams_Subjects_SubjectId",
table: "MinorExams");
migrationBuilder.DropPrimaryKey(
name: "PK_MinorExams",
table: "MinorExams");
migrationBuilder.DropPrimaryKey(
name: "PK_Comments",
table: "Comments");
migrationBuilder.DropPrimaryKey(
name: "PK_Assignments",
table: "Assignments");
migrationBuilder.RenameTable(
name: "MinorExams",
newName: "MinorExam");
migrationBuilder.RenameTable(
name: "Comments",
newName: "Comment");
migrationBuilder.RenameTable(
name: "Assignments",
newName: "Assignment");
migrationBuilder.RenameColumn(
name: "SubjectId",
table: "MinorExam",
newName: "SubjectID");
migrationBuilder.RenameIndex(
name: "IX_MinorExams_SubjectId",
table: "MinorExam",
newName: "IX_MinorExam_SubjectID");
migrationBuilder.RenameColumn(
name: "SubjectId",
table: "Comment",
newName: "SubjectID");
migrationBuilder.RenameIndex(
name: "IX_Comments_SubjectId",
table: "Comment",
newName: "IX_Comment_SubjectID");
migrationBuilder.RenameColumn(
name: "SubjectId",
table: "Assignment",
newName: "SubjectID");
migrationBuilder.RenameIndex(
name: "IX_Assignments_SubjectId",
table: "Assignment",
newName: "IX_Assignment_SubjectID");
migrationBuilder.AddPrimaryKey(
name: "PK_MinorExam",
table: "MinorExam",
column: "ID");
migrationBuilder.AddPrimaryKey(
name: "PK_Comment",
table: "Comment",
column: "ID");
migrationBuilder.AddPrimaryKey(
name: "PK_Assignment",
table: "Assignment",
column: "ID");
migrationBuilder.AddForeignKey(
name: "FK_Assignment_Subjects_SubjectID",
table: "Assignment",
column: "SubjectID",
principalTable: "Subjects",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Comment_Subjects_SubjectID",
table: "Comment",
column: "SubjectID",
principalTable: "Subjects",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_MinorExam_Subjects_SubjectID",
table: "MinorExam",
column: "SubjectID",
principalTable: "Subjects",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}