124 lines
5.1 KiB
C#
124 lines
5.1 KiB
C#
|
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<long>(type: "bigint", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
LectureTeacher = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|||
|
LabTeacher = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|||
|
MainExam = table.Column<bool>(type: "bit", nullable: false),
|
|||
|
ExamDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Subjects", x => x.ID);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Assignment",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
ID = table.Column<long>(type: "bigint", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Deadline = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
FinalMarkPercent = table.Column<double>(type: "float", nullable: false),
|
|||
|
SubjectID = table.Column<long>(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<long>(type: "bigint", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
SubjectID = table.Column<long>(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<long>(type: "bigint", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
Scope = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
FinalMarkPercent = table.Column<double>(type: "float", nullable: false),
|
|||
|
SubjectID = table.Column<long>(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");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|