study-lib-backend/Migrations/20201223201708_AddedGroupToSubject.cs

76 lines
2.4 KiB
C#
Raw Normal View History

2020-12-23 23:35:08 +01:00
using Microsoft.EntityFrameworkCore.Migrations;
namespace StudyLib.Migrations
{
public partial class AddedGroupToSubject : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Subjects_Groups_GroupID",
table: "Subjects");
migrationBuilder.RenameColumn(
name: "GroupID",
table: "Subjects",
newName: "GroupId");
migrationBuilder.RenameIndex(
name: "IX_Subjects_GroupID",
table: "Subjects",
newName: "IX_Subjects_GroupId");
migrationBuilder.AlterColumn<long>(
name: "GroupId",
table: "Subjects",
type: "bigint",
nullable: false,
defaultValue: 0L,
oldClrType: typeof(long),
oldType: "bigint",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Subjects_Groups_GroupId",
table: "Subjects",
column: "GroupId",
principalTable: "Groups",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Subjects_Groups_GroupId",
table: "Subjects");
migrationBuilder.RenameColumn(
name: "GroupId",
table: "Subjects",
newName: "GroupID");
migrationBuilder.RenameIndex(
name: "IX_Subjects_GroupId",
table: "Subjects",
newName: "IX_Subjects_GroupID");
migrationBuilder.AlterColumn<long>(
name: "GroupID",
table: "Subjects",
type: "bigint",
nullable: true,
oldClrType: typeof(long),
oldType: "bigint");
migrationBuilder.AddForeignKey(
name: "FK_Subjects_Groups_GroupID",
table: "Subjects",
column: "GroupID",
principalTable: "Groups",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
}
}
}