using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
///
public partial class CourseAdjustments : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CourseAdjustments",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
TeachingTaskId = table.Column(type: "char(36)", nullable: false),
Type = table.Column(type: "int", nullable: false),
Status = table.Column(type: "int", nullable: false),
ApplicantUserId = table.Column(type: "char(36)", nullable: false),
TargetDate = table.Column(type: "date", nullable: true),
DayOfWeek = table.Column(type: "int", nullable: true),
StartPeriod = table.Column(type: "int", nullable: true),
PeriodCount = table.Column(type: "int", nullable: true),
ClassroomId = table.Column(type: "char(36)", nullable: true),
SubstituteTeacherId = table.Column(type: "char(36)", nullable: true),
CancelWeek = table.Column(type: "int", nullable: true),
CancelDate = table.Column(type: "date", nullable: true),
Reason = table.Column(type: "varchar(500)", maxLength: 500, nullable: false),
ReviewComment = table.Column(type: "varchar(500)", maxLength: 500, nullable: true),
SubmittedAt = table.Column(type: "datetime(6)", nullable: true),
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_CourseAdjustments", x => x.Id);
table.ForeignKey(
name: "FK_CourseAdjustments_Classrooms_ClassroomId",
column: x => x.ClassroomId,
principalTable: "Classrooms",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_CourseAdjustments_Teachers_SubstituteTeacherId",
column: x => x.SubstituteTeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_CourseAdjustments_TeachingTasks_TeachingTaskId",
column: x => x.TeachingTaskId,
principalTable: "TeachingTasks",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Notifications",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
UserId = table.Column(type: "char(36)", nullable: false),
Title = table.Column(type: "varchar(200)", maxLength: 200, nullable: false),
Content = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: false),
IsRead = table.Column(type: "tinyint(1)", nullable: false),
LinkUrl = table.Column(type: "varchar(300)", maxLength: 300, nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notifications", x => x.Id);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_CourseAdjustments_ApplicantUserId",
table: "CourseAdjustments",
column: "ApplicantUserId");
migrationBuilder.CreateIndex(
name: "IX_CourseAdjustments_ClassroomId",
table: "CourseAdjustments",
column: "ClassroomId");
migrationBuilder.CreateIndex(
name: "IX_CourseAdjustments_Status_CreatedAt",
table: "CourseAdjustments",
columns: new[] { "Status", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_CourseAdjustments_SubstituteTeacherId",
table: "CourseAdjustments",
column: "SubstituteTeacherId");
migrationBuilder.CreateIndex(
name: "IX_CourseAdjustments_TeachingTaskId_Status",
table: "CourseAdjustments",
columns: new[] { "TeachingTaskId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_Notifications_CreatedAt",
table: "Notifications",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_Notifications_UserId_IsRead",
table: "Notifications",
columns: new[] { "UserId", "IsRead" });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(name: "Notifications");
migrationBuilder.DropTable(name: "CourseAdjustments");
}
}
}