107 lines
4.8 KiB
C#
107 lines
4.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class TeacherCourseApplications : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "GenerationBatchCode",
|
|
table: "TeachingTasks",
|
|
type: "varchar(40)",
|
|
maxLength: 40,
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TeacherCourseApplications",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
AcademicTermId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
TeacherId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
CourseId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
Statement = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true),
|
|
ReviewComment = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true),
|
|
SubmittedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
ReviewedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
ReviewedByUserId = table.Column<Guid>(type: "char(36)", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "TeacherCourseApplications");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "GenerationBatchCode",
|
|
table: "TeachingTasks");
|
|
}
|
|
}
|
|
}
|