using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
///
public partial class TeacherCourseApplications : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "GenerationBatchCode",
table: "TeachingTasks",
type: "varchar(40)",
maxLength: 40,
nullable: true);
migrationBuilder.CreateTable(
name: "TeacherCourseApplications",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
AcademicTermId = table.Column(type: "char(36)", nullable: false),
TeacherId = table.Column(type: "char(36)", nullable: false),
CourseId = table.Column(type: "char(36)", nullable: false),
Status = table.Column(type: "int", nullable: false),
Statement = table.Column(type: "varchar(500)", maxLength: 500, nullable: true),
ReviewComment = table.Column(type: "varchar(500)", maxLength: 500, nullable: true),
SubmittedAt = table.Column(type: "datetime(6)", nullable: false),
ReviewedAt = table.Column(type: "datetime(6)", nullable: true),
ReviewedByUserId = table.Column(type: "char(36)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeacherCourseApplications", x => x.Id);
table.ForeignKey(
name: "FK_TeacherCourseApplications_AcademicTerms_AcademicTermId",
column: x => x.AcademicTermId,
principalTable: "AcademicTerms",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_TeacherCourseApplications_AspNetUsers_ReviewedByUserId",
column: x => x.ReviewedByUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_TeacherCourseApplications_Courses_CourseId",
column: x => x.CourseId,
principalTable: "Courses",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_TeacherCourseApplications_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_TeacherCourseApplications_AcademicTermId_TeacherId_CourseId",
table: "TeacherCourseApplications",
columns: new[] { "AcademicTermId", "TeacherId", "CourseId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TeacherCourseApplications_CourseId",
table: "TeacherCourseApplications",
column: "CourseId");
migrationBuilder.CreateIndex(
name: "IX_TeacherCourseApplications_ReviewedByUserId",
table: "TeacherCourseApplications",
column: "ReviewedByUserId");
migrationBuilder.CreateIndex(
name: "IX_TeacherCourseApplications_Status_AcademicTermId",
table: "TeacherCourseApplications",
columns: new[] { "Status", "AcademicTermId" });
migrationBuilder.CreateIndex(
name: "IX_TeacherCourseApplications_TeacherId",
table: "TeacherCourseApplications",
column: "TeacherId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TeacherCourseApplications");
migrationBuilder.DropColumn(
name: "GenerationBatchCode",
table: "TeachingTasks");
}
}
}