882 lines
44 KiB
C#
882 lines
44 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|
|
|
namespace TechHelper.Server.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetRoles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
NormalizedName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetUsers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RefreshToken = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
RefreshTokenExpiryTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
Address = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
DisplayName = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
NormalizedUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Email = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
NormalizedEmail = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
PasswordHash = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SecurityStamp = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
PhoneNumber = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
PhoneNumberConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
TwoFactorEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
LockoutEnd = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
|
|
LockoutEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "QuestionContexts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Description = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_QuestionContexts", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "textbook",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Grade = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
Title = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Publisher = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
SubjectArea = table.Column<byte>(type: "tinyint unsigned", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_textbook", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetRoleClaims",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ClaimType = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
|
column: x => x.RoleId,
|
|
principalTable: "AspNetRoles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetUserClaims",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ClaimType = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetUserLogins",
|
|
columns: table => new
|
|
{
|
|
LoginProvider = table.Column<string>(type: "varchar(255)", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ProviderKey = table.Column<string>(type: "varchar(255)", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ProviderDisplayName = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
|
table.ForeignKey(
|
|
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetUserRoles",
|
|
columns: table => new
|
|
{
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
|
table.ForeignKey(
|
|
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
|
column: x => x.RoleId,
|
|
principalTable: "AspNetRoles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AspNetUserTokens",
|
|
columns: table => new
|
|
{
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
LoginProvider = table.Column<string>(type: "varchar(255)", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Name = table.Column<string>(type: "varchar(255)", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Value = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
|
table.ForeignKey(
|
|
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "assignments",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
title = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
description = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
subject_area = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
due_date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
total_points = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
score = table.Column<float>(type: "float", nullable: false),
|
|
created_by = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
created_at = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
updated_at = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_assignments", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_assignments_AspNetUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_assignments_AspNetUsers_created_by",
|
|
column: x => x.created_by,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "classes",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
grade = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
@class = table.Column<byte>(name: "class", type: "tinyint unsigned", nullable: false),
|
|
description = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
head_teacher_id = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
created_at = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
updated_at = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_classes", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_classes_AspNetUsers_head_teacher_id",
|
|
column: x => x.head_teacher_id,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "lesson",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Title = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Description = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
TextbookID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_lesson", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_lesson_textbook_TextbookID",
|
|
column: x => x.TextbookID,
|
|
principalTable: "textbook",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "assignment_attachments",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
assignment_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
file_path = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
file_name = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
uploaded_at = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_assignment_attachments", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_assignment_attachments_assignments_assignment_id",
|
|
column: x => x.assignment_id,
|
|
principalTable: "assignments",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "submissions",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
assignment_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
student_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
attempt_number = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
submission_time = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
overall_grade = table.Column<float>(type: "float", precision: 5, scale: 2, nullable: true),
|
|
overall_feedback = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
graded_by = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
graded_at = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
|
|
status = table.Column<int>(type: "int", maxLength: 15, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_submissions", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_submissions_AspNetUsers_graded_by",
|
|
column: x => x.graded_by,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_submissions_AspNetUsers_student_id",
|
|
column: x => x.student_id,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_submissions_assignments_assignment_id",
|
|
column: x => x.assignment_id,
|
|
principalTable: "assignments",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "assignment_class",
|
|
columns: table => new
|
|
{
|
|
assignment_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
class_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
assigned_at = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_assignment_class", x => new { x.assignment_id, x.class_id });
|
|
table.ForeignKey(
|
|
name: "FK_assignment_class_assignments_assignment_id",
|
|
column: x => x.assignment_id,
|
|
principalTable: "assignments",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_assignment_class_classes_class_id",
|
|
column: x => x.class_id,
|
|
principalTable: "classes",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "class_student",
|
|
columns: table => new
|
|
{
|
|
class_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
student_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
enrollment_date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_class_student", x => new { x.class_id, x.student_id });
|
|
table.ForeignKey(
|
|
name: "FK_class_student_AspNetUsers_student_id",
|
|
column: x => x.student_id,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_class_student_classes_class_id",
|
|
column: x => x.class_id,
|
|
principalTable: "classes",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "class_teachers",
|
|
columns: table => new
|
|
{
|
|
class_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
teacher_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
subject_taught = table.Column<byte>(type: "tinyint unsigned", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_class_teachers", x => new { x.class_id, x.teacher_id });
|
|
table.ForeignKey(
|
|
name: "FK_class_teachers_AspNetUsers_teacher_id",
|
|
column: x => x.teacher_id,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_class_teachers_classes_class_id",
|
|
column: x => x.class_id,
|
|
principalTable: "classes",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "key_point",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Key = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
LessonID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_key_point", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_key_point_lesson_LessonID",
|
|
column: x => x.LessonID,
|
|
principalTable: "lesson",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "lesson_question",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Question = table.Column<string>(type: "longtext", maxLength: 65535, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
LessonID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_lesson_question", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_lesson_question_lesson_LessonID",
|
|
column: x => x.LessonID,
|
|
principalTable: "lesson",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "questions",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
question_text = table.Column<string>(type: "longtext", maxLength: 65535, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
correct_answer = table.Column<string>(type: "longtext", maxLength: 65535, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
question_type = table.Column<byte>(type: "tinyint unsigned", maxLength: 20, nullable: false),
|
|
difficulty_level = table.Column<byte>(type: "tinyint unsigned", maxLength: 10, nullable: false),
|
|
subject_area = table.Column<byte>(type: "tinyint unsigned", maxLength: 100, nullable: false),
|
|
options = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
key_point = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
lesson = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
created_by = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
created_at = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
updated_at = table.Column<DateTime>(type: "datetime(6)", rowVersion: true, nullable: false),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_questions", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_questions_AspNetUsers_created_by",
|
|
column: x => x.created_by,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_questions_key_point_key_point",
|
|
column: x => x.key_point,
|
|
principalTable: "key_point",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_questions_lesson_lesson",
|
|
column: x => x.lesson,
|
|
principalTable: "lesson",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "assignment_questions",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
question_id = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
assignment = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
title = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
description = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
question_number = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
parent_question_group_id = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
group_state = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
created_at = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
score = table.Column<float>(type: "float", nullable: true),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_assignment_questions", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_assignment_questions_QuestionContexts_description",
|
|
column: x => x.description,
|
|
principalTable: "QuestionContexts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_assignment_questions_assignment_questions_parent_question_gr~",
|
|
column: x => x.parent_question_group_id,
|
|
principalTable: "assignment_questions",
|
|
principalColumn: "id");
|
|
table.ForeignKey(
|
|
name: "FK_assignment_questions_assignments_assignment",
|
|
column: x => x.assignment,
|
|
principalTable: "assignments",
|
|
principalColumn: "id");
|
|
table.ForeignKey(
|
|
name: "FK_assignment_questions_questions_question_id",
|
|
column: x => x.question_id,
|
|
principalTable: "questions",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "submission_details",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
submission_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
student_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
assignment_question_id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
student_answer = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
is_correct = table.Column<bool>(type: "tinyint(1)", nullable: true),
|
|
points_awarded = table.Column<float>(type: "float", precision: 5, scale: 2, nullable: true),
|
|
teacher_feedback = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
created_at = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
updated_at = table.Column<DateTime>(type: "datetime(6)", rowVersion: true, nullable: false),
|
|
deleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_submission_details", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_submission_details_AspNetUsers_student_id",
|
|
column: x => x.student_id,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_submission_details_assignment_questions_assignment_question_~",
|
|
column: x => x.assignment_question_id,
|
|
principalTable: "assignment_questions",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_submission_details_submissions_submission_id",
|
|
column: x => x.submission_id,
|
|
principalTable: "submissions",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "AspNetRoles",
|
|
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
|
values: new object[,]
|
|
{
|
|
{ new Guid("04b04eed-32b9-4eb0-b5f5-a97bb4626718"), null, "Teacher", "TEACHER" },
|
|
{ new Guid("577dbfe8-7b77-4ead-9386-678f02dea5f4"), null, "Student", "STUDENT" },
|
|
{ new Guid("82354e4d-902d-4dd6-9790-6ef50ba9bc11"), null, "Administrator", "ADMINISTRATOR" }
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AspNetRoleClaims_RoleId",
|
|
table: "AspNetRoleClaims",
|
|
column: "RoleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "RoleNameIndex",
|
|
table: "AspNetRoles",
|
|
column: "NormalizedName",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AspNetUserClaims_UserId",
|
|
table: "AspNetUserClaims",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AspNetUserLogins_UserId",
|
|
table: "AspNetUserLogins",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AspNetUserRoles_RoleId",
|
|
table: "AspNetUserRoles",
|
|
column: "RoleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "EmailIndex",
|
|
table: "AspNetUsers",
|
|
column: "NormalizedEmail");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "UserNameIndex",
|
|
table: "AspNetUsers",
|
|
column: "NormalizedUserName",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignment_attachments_assignment_id",
|
|
table: "assignment_attachments",
|
|
column: "assignment_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignment_class_class_id",
|
|
table: "assignment_class",
|
|
column: "class_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignment_questions_assignment",
|
|
table: "assignment_questions",
|
|
column: "assignment",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignment_questions_description",
|
|
table: "assignment_questions",
|
|
column: "description");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignment_questions_parent_question_group_id",
|
|
table: "assignment_questions",
|
|
column: "parent_question_group_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignment_questions_question_id",
|
|
table: "assignment_questions",
|
|
column: "question_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignments_created_by",
|
|
table: "assignments",
|
|
column: "created_by");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_assignments_UserId",
|
|
table: "assignments",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_class_student_student_id",
|
|
table: "class_student",
|
|
column: "student_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_class_teachers_teacher_id",
|
|
table: "class_teachers",
|
|
column: "teacher_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_classes_head_teacher_id",
|
|
table: "classes",
|
|
column: "head_teacher_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_key_point_LessonID",
|
|
table: "key_point",
|
|
column: "LessonID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_lesson_TextbookID",
|
|
table: "lesson",
|
|
column: "TextbookID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_lesson_question_LessonID",
|
|
table: "lesson_question",
|
|
column: "LessonID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_questions_created_by",
|
|
table: "questions",
|
|
column: "created_by");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_questions_key_point",
|
|
table: "questions",
|
|
column: "key_point");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_questions_lesson",
|
|
table: "questions",
|
|
column: "lesson");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_questions_question_text",
|
|
table: "questions",
|
|
column: "question_text")
|
|
.Annotation("MySql:IndexPrefixLength", new[] { 20 });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_submission_details_assignment_question_id",
|
|
table: "submission_details",
|
|
column: "assignment_question_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_submission_details_student_id",
|
|
table: "submission_details",
|
|
column: "student_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_submission_details_submission_id",
|
|
table: "submission_details",
|
|
column: "submission_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_submissions_assignment_id",
|
|
table: "submissions",
|
|
column: "assignment_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_submissions_graded_by",
|
|
table: "submissions",
|
|
column: "graded_by");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_submissions_student_id",
|
|
table: "submissions",
|
|
column: "student_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetRoleClaims");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetUserClaims");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetUserLogins");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetUserRoles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetUserTokens");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "assignment_attachments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "assignment_class");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "class_student");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "class_teachers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "lesson_question");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "submission_details");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetRoles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "classes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "assignment_questions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "submissions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "QuestionContexts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "questions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "assignments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "key_point");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetUsers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "lesson");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "textbook");
|
|
}
|
|
}
|
|
}
|