make migration

This commit is contained in:
MaxKarme 2023-04-09 01:20:49 +04:00
parent d07365e746
commit aa08035ab4
4 changed files with 1386 additions and 0 deletions

View File

@ -0,0 +1,497 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using UniversityDatabaseImplement;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
[DbContext(typeof(UniversityDatabase))]
[Migration("20230408211938_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("UniversityDatabaseImplement.Models.Activity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int?>("ExaminationResultId")
.HasColumnType("integer");
b.Property<int>("Number")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ExaminationResultId");
b.ToTable("Activities");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Department")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Disciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ExaminationResult", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("ExaminationForm")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int?>("StatementId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StatementId");
b.ToTable("ExaminationResults");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ReportTypes");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeActivity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ActivityId")
.HasColumnType("integer");
b.Property<int>("ReportTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ActivityId");
b.HasIndex("ReportTypeId");
b.ToTable("ReportTypeActivities");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeDiscipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("DisciplineId")
.HasColumnType("integer");
b.Property<int>("ReportTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DisciplineId");
b.HasIndex("ReportTypeId");
b.ToTable("ReportTypeDisciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int?>("DisciplineId")
.HasColumnType("integer");
b.Property<int>("HoursCount")
.HasColumnType("integer");
b.Property<int?>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DisciplineId");
b.HasIndex("UserId");
b.ToTable("Statements");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StatementStudent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("StatementId")
.HasColumnType("integer");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.Property<int>("StudentTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StatementId");
b.HasIndex("StudentId");
b.ToTable("StatementStudents");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RecordCardNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Students");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentExaminationResult", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ExaminationResultId")
.HasColumnType("integer");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ExaminationResultId");
b.HasIndex("StudentId");
b.ToTable("StudentExaminationResults");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.UserStudent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("StudentId")
.HasColumnType("integer");
b.Property<int>("StudentTypeId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StudentId");
b.HasIndex("UserId");
b.ToTable("UserStudents");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Activity", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.ExaminationResult", null)
.WithMany("Activities")
.HasForeignKey("ExaminationResultId");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ExaminationResult", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Statement", null)
.WithMany("ExaminationResults")
.HasForeignKey("StatementId");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeActivity", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Activity", "Activity")
.WithMany("ReportTypeActivities")
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.ReportType", "ReportType")
.WithMany("ReportTypeActivities")
.HasForeignKey("ReportTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Activity");
b.Navigation("ReportType");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeDiscipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("ReportTypeDisciplines")
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.ReportType", "ReportType")
.WithMany("ReportTypeDisciplines")
.HasForeignKey("ReportTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Discipline");
b.Navigation("ReportType");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", null)
.WithMany("Statements")
.HasForeignKey("DisciplineId");
b.HasOne("UniversityDatabaseImplement.Models.User", null)
.WithMany("Statements")
.HasForeignKey("UserId");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StatementStudent", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Statement", "Statement")
.WithMany("StatementStudents")
.HasForeignKey("StatementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StatementStudents")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Statement");
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentExaminationResult", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.ExaminationResult", "ExaminationResult")
.WithMany("StudentExaminationResults")
.HasForeignKey("ExaminationResultId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StudentExaminationResults")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ExaminationResult");
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.UserStudent", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StudentUsers")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("StudentUsers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Student");
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Activity", b =>
{
b.Navigation("ReportTypeActivities");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Navigation("ReportTypeDisciplines");
b.Navigation("Statements");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ExaminationResult", b =>
{
b.Navigation("Activities");
b.Navigation("StudentExaminationResults");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportType", b =>
{
b.Navigation("ReportTypeActivities");
b.Navigation("ReportTypeDisciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.Navigation("ExaminationResults");
b.Navigation("StatementStudents");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.Navigation("StatementStudents");
b.Navigation("StudentExaminationResults");
b.Navigation("StudentUsers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
{
b.Navigation("Statements");
b.Navigation("StudentUsers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,384 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Disciplines",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Department = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Disciplines", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ReportTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ReportTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
RecordCardNumber = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: false),
Position = table.Column<string>(type: "text", nullable: false),
Login = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ReportTypeDisciplines",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ReportTypeId = table.Column<int>(type: "integer", nullable: false),
DisciplineId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ReportTypeDisciplines", x => x.Id);
table.ForeignKey(
name: "FK_ReportTypeDisciplines_Disciplines_DisciplineId",
column: x => x.DisciplineId,
principalTable: "Disciplines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ReportTypeDisciplines_ReportTypes_ReportTypeId",
column: x => x.ReportTypeId,
principalTable: "ReportTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Statements",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
HoursCount = table.Column<int>(type: "integer", nullable: false),
DisciplineId = table.Column<int>(type: "integer", nullable: true),
UserId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Statements", x => x.Id);
table.ForeignKey(
name: "FK_Statements_Disciplines_DisciplineId",
column: x => x.DisciplineId,
principalTable: "Disciplines",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Statements_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "UserStudents",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StudentTypeId = table.Column<int>(type: "integer", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
StudentId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserStudents", x => x.Id);
table.ForeignKey(
name: "FK_UserStudents_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserStudents_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ExaminationResults",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ExaminationForm = table.Column<string>(type: "text", nullable: false),
Mark = table.Column<int>(type: "integer", nullable: false),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
StatementId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ExaminationResults", x => x.Id);
table.ForeignKey(
name: "FK_ExaminationResults_Statements_StatementId",
column: x => x.StatementId,
principalTable: "Statements",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "StatementStudents",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StudentTypeId = table.Column<int>(type: "integer", nullable: false),
StatementId = table.Column<int>(type: "integer", nullable: false),
StudentId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StatementStudents", x => x.Id);
table.ForeignKey(
name: "FK_StatementStudents_Statements_StatementId",
column: x => x.StatementId,
principalTable: "Statements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StatementStudents_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Activities",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Number = table.Column<int>(type: "integer", nullable: false),
ExaminationResultId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Activities", x => x.Id);
table.ForeignKey(
name: "FK_Activities_ExaminationResults_ExaminationResultId",
column: x => x.ExaminationResultId,
principalTable: "ExaminationResults",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "StudentExaminationResults",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ExaminationResultId = table.Column<int>(type: "integer", nullable: false),
StudentId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StudentExaminationResults", x => x.Id);
table.ForeignKey(
name: "FK_StudentExaminationResults_ExaminationResults_ExaminationRes~",
column: x => x.ExaminationResultId,
principalTable: "ExaminationResults",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StudentExaminationResults_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ReportTypeActivities",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ReportTypeId = table.Column<int>(type: "integer", nullable: false),
ActivityId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ReportTypeActivities", x => x.Id);
table.ForeignKey(
name: "FK_ReportTypeActivities_Activities_ActivityId",
column: x => x.ActivityId,
principalTable: "Activities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ReportTypeActivities_ReportTypes_ReportTypeId",
column: x => x.ReportTypeId,
principalTable: "ReportTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Activities_ExaminationResultId",
table: "Activities",
column: "ExaminationResultId");
migrationBuilder.CreateIndex(
name: "IX_ExaminationResults_StatementId",
table: "ExaminationResults",
column: "StatementId");
migrationBuilder.CreateIndex(
name: "IX_ReportTypeActivities_ActivityId",
table: "ReportTypeActivities",
column: "ActivityId");
migrationBuilder.CreateIndex(
name: "IX_ReportTypeActivities_ReportTypeId",
table: "ReportTypeActivities",
column: "ReportTypeId");
migrationBuilder.CreateIndex(
name: "IX_ReportTypeDisciplines_DisciplineId",
table: "ReportTypeDisciplines",
column: "DisciplineId");
migrationBuilder.CreateIndex(
name: "IX_ReportTypeDisciplines_ReportTypeId",
table: "ReportTypeDisciplines",
column: "ReportTypeId");
migrationBuilder.CreateIndex(
name: "IX_Statements_DisciplineId",
table: "Statements",
column: "DisciplineId");
migrationBuilder.CreateIndex(
name: "IX_Statements_UserId",
table: "Statements",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_StatementStudents_StatementId",
table: "StatementStudents",
column: "StatementId");
migrationBuilder.CreateIndex(
name: "IX_StatementStudents_StudentId",
table: "StatementStudents",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_StudentExaminationResults_ExaminationResultId",
table: "StudentExaminationResults",
column: "ExaminationResultId");
migrationBuilder.CreateIndex(
name: "IX_StudentExaminationResults_StudentId",
table: "StudentExaminationResults",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_UserStudents_StudentId",
table: "UserStudents",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_UserStudents_UserId",
table: "UserStudents",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ReportTypeActivities");
migrationBuilder.DropTable(
name: "ReportTypeDisciplines");
migrationBuilder.DropTable(
name: "StatementStudents");
migrationBuilder.DropTable(
name: "StudentExaminationResults");
migrationBuilder.DropTable(
name: "UserStudents");
migrationBuilder.DropTable(
name: "Activities");
migrationBuilder.DropTable(
name: "ReportTypes");
migrationBuilder.DropTable(
name: "Students");
migrationBuilder.DropTable(
name: "ExaminationResults");
migrationBuilder.DropTable(
name: "Statements");
migrationBuilder.DropTable(
name: "Disciplines");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@ -0,0 +1,494 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using UniversityDatabaseImplement;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
[DbContext(typeof(UniversityDatabase))]
partial class UniversityDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("UniversityDatabaseImplement.Models.Activity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int?>("ExaminationResultId")
.HasColumnType("integer");
b.Property<int>("Number")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ExaminationResultId");
b.ToTable("Activities");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Department")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Disciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ExaminationResult", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("ExaminationForm")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int?>("StatementId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StatementId");
b.ToTable("ExaminationResults");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ReportTypes");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeActivity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ActivityId")
.HasColumnType("integer");
b.Property<int>("ReportTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ActivityId");
b.HasIndex("ReportTypeId");
b.ToTable("ReportTypeActivities");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeDiscipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("DisciplineId")
.HasColumnType("integer");
b.Property<int>("ReportTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DisciplineId");
b.HasIndex("ReportTypeId");
b.ToTable("ReportTypeDisciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int?>("DisciplineId")
.HasColumnType("integer");
b.Property<int>("HoursCount")
.HasColumnType("integer");
b.Property<int?>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DisciplineId");
b.HasIndex("UserId");
b.ToTable("Statements");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StatementStudent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("StatementId")
.HasColumnType("integer");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.Property<int>("StudentTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StatementId");
b.HasIndex("StudentId");
b.ToTable("StatementStudents");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RecordCardNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Students");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentExaminationResult", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ExaminationResultId")
.HasColumnType("integer");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ExaminationResultId");
b.HasIndex("StudentId");
b.ToTable("StudentExaminationResults");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.UserStudent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("StudentId")
.HasColumnType("integer");
b.Property<int>("StudentTypeId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StudentId");
b.HasIndex("UserId");
b.ToTable("UserStudents");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Activity", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.ExaminationResult", null)
.WithMany("Activities")
.HasForeignKey("ExaminationResultId");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ExaminationResult", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Statement", null)
.WithMany("ExaminationResults")
.HasForeignKey("StatementId");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeActivity", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Activity", "Activity")
.WithMany("ReportTypeActivities")
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.ReportType", "ReportType")
.WithMany("ReportTypeActivities")
.HasForeignKey("ReportTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Activity");
b.Navigation("ReportType");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportTypeDiscipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("ReportTypeDisciplines")
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.ReportType", "ReportType")
.WithMany("ReportTypeDisciplines")
.HasForeignKey("ReportTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Discipline");
b.Navigation("ReportType");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", null)
.WithMany("Statements")
.HasForeignKey("DisciplineId");
b.HasOne("UniversityDatabaseImplement.Models.User", null)
.WithMany("Statements")
.HasForeignKey("UserId");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StatementStudent", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Statement", "Statement")
.WithMany("StatementStudents")
.HasForeignKey("StatementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StatementStudents")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Statement");
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentExaminationResult", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.ExaminationResult", "ExaminationResult")
.WithMany("StudentExaminationResults")
.HasForeignKey("ExaminationResultId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StudentExaminationResults")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ExaminationResult");
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.UserStudent", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StudentUsers")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("StudentUsers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Student");
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Activity", b =>
{
b.Navigation("ReportTypeActivities");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Navigation("ReportTypeDisciplines");
b.Navigation("Statements");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ExaminationResult", b =>
{
b.Navigation("Activities");
b.Navigation("StudentExaminationResults");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.ReportType", b =>
{
b.Navigation("ReportTypeActivities");
b.Navigation("ReportTypeDisciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.Navigation("ExaminationResults");
b.Navigation("StatementStudents");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.Navigation("StatementStudents");
b.Navigation("StudentExaminationResults");
b.Navigation("StudentUsers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
{
b.Navigation("Statements");
b.Navigation("StudentUsers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -8,4 +8,15 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DatabaseImplement\UniversityDatabaseImplement.csproj" />
</ItemGroup>
</Project>