using System; using Microsoft.EntityFrameworkCore.Migrations; namespace StudyLib.Migrations { public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Subjects", columns: table => new { ID = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), LectureTeacher = table.Column(type: "nvarchar(max)", nullable: true), LabTeacher = table.Column(type: "nvarchar(max)", nullable: true), MainExam = table.Column(type: "bit", nullable: false), ExamDate = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Subjects", x => x.ID); }); migrationBuilder.CreateTable( name: "Assignment", columns: table => new { ID = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Deadline = table.Column(type: "datetime2", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), FinalMarkPercent = table.Column(type: "float", nullable: false), SubjectID = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Assignment", x => x.ID); table.ForeignKey( name: "FK_Assignment_Subjects_SubjectID", column: x => x.SubjectID, principalTable: "Subjects", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Comment", columns: table => new { ID = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Text = table.Column(type: "nvarchar(max)", nullable: false), SubjectID = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Comment", x => x.ID); table.ForeignKey( name: "FK_Comment_Subjects_SubjectID", column: x => x.SubjectID, principalTable: "Subjects", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MinorExam", columns: table => new { ID = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Date = table.Column(type: "datetime2", nullable: false), Scope = table.Column(type: "nvarchar(max)", nullable: false), FinalMarkPercent = table.Column(type: "float", nullable: false), SubjectID = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MinorExam", x => x.ID); table.ForeignKey( name: "FK_MinorExam_Subjects_SubjectID", column: x => x.SubjectID, principalTable: "Subjects", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Assignment_SubjectID", table: "Assignment", column: "SubjectID"); migrationBuilder.CreateIndex( name: "IX_Comment_SubjectID", table: "Comment", column: "SubjectID"); migrationBuilder.CreateIndex( name: "IX_MinorExam_SubjectID", table: "MinorExam", column: "SubjectID"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Assignment"); migrationBuilder.DropTable( name: "Comment"); migrationBuilder.DropTable( name: "MinorExam"); migrationBuilder.DropTable( name: "Subjects"); } } }