PIbd-21_Pyatakov_KM_Markov_.../UniversityDataBaseImplemet/Migrations/20230518002601_nullableEdStatusId4.cs
Danil Markov 7e3706b2f6 Documents - нужно сделать update и пофиксить delete.
многие ко многим работает (нужен фикс update и delete)
2023-05-18 04:35:12 +04:00

223 lines
8.2 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace UniversityDataBaseImplemet.Migrations
{
/// <inheritdoc />
public partial class nullableEdStatusId4 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Documents_User_UserId",
table: "Documents");
migrationBuilder.DropPrimaryKey(
name: "PK_StudentStreams",
table: "StudentStreams");
migrationBuilder.DropIndex(
name: "IX_StudentStreams_StudentId",
table: "StudentStreams");
migrationBuilder.DropPrimaryKey(
name: "PK_StudentDocuments",
table: "StudentDocuments");
migrationBuilder.DropIndex(
name: "IX_StudentDocuments_StudentId",
table: "StudentDocuments");
migrationBuilder.DropPrimaryKey(
name: "PK_EducationGroupsStreams",
table: "EducationGroupsStreams");
migrationBuilder.DropIndex(
name: "IX_EducationGroupsStreams_EducationGroupId",
table: "EducationGroupsStreams");
migrationBuilder.DropPrimaryKey(
name: "PK_EducationGroupsDocuments",
table: "EducationGroupsDocuments");
migrationBuilder.DropIndex(
name: "IX_EducationGroupsDocuments_EducationGroupId",
table: "EducationGroupsDocuments");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "StudentStreams",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "StudentDocuments",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "EducationGroupsStreams",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "EducationGroupsDocuments",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AddPrimaryKey(
name: "PK_StudentStreams",
table: "StudentStreams",
columns: new[] { "StudentId", "StreamId" });
migrationBuilder.AddPrimaryKey(
name: "PK_StudentDocuments",
table: "StudentDocuments",
columns: new[] { "StudentId", "DocumentId" });
migrationBuilder.AddPrimaryKey(
name: "PK_EducationGroupsStreams",
table: "EducationGroupsStreams",
columns: new[] { "EducationGroupId", "StreamId" });
migrationBuilder.AddPrimaryKey(
name: "PK_EducationGroupsDocuments",
table: "EducationGroupsDocuments",
columns: new[] { "EducationGroupId", "DocumentId" });
migrationBuilder.AddForeignKey(
name: "FK_Documents_User_UserId",
table: "Documents",
column: "UserId",
principalTable: "User",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Documents_User_UserId",
table: "Documents");
migrationBuilder.DropPrimaryKey(
name: "PK_StudentStreams",
table: "StudentStreams");
migrationBuilder.DropPrimaryKey(
name: "PK_StudentDocuments",
table: "StudentDocuments");
migrationBuilder.DropPrimaryKey(
name: "PK_EducationGroupsStreams",
table: "EducationGroupsStreams");
migrationBuilder.DropPrimaryKey(
name: "PK_EducationGroupsDocuments",
table: "EducationGroupsDocuments");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "StudentStreams",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "StudentDocuments",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "EducationGroupsStreams",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "EducationGroupsDocuments",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AddPrimaryKey(
name: "PK_StudentStreams",
table: "StudentStreams",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_StudentDocuments",
table: "StudentDocuments",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_EducationGroupsStreams",
table: "EducationGroupsStreams",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_EducationGroupsDocuments",
table: "EducationGroupsDocuments",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_StudentStreams_StudentId",
table: "StudentStreams",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_StudentDocuments_StudentId",
table: "StudentDocuments",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_EducationGroupsStreams_EducationGroupId",
table: "EducationGroupsStreams",
column: "EducationGroupId");
migrationBuilder.CreateIndex(
name: "IX_EducationGroupsDocuments_EducationGroupId",
table: "EducationGroupsDocuments",
column: "EducationGroupId");
migrationBuilder.AddForeignKey(
name: "FK_Documents_User_UserId",
table: "Documents",
column: "UserId",
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}