Files
Academic-Affairs-System/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20260809075833_PublishedTimetableOccurrences.cs
T
biss 26a918a52a 新增 PublishedScheduleOccurrences:发布时将周期规则按实际周次展开为只读课次明细。
明细保留课表版本、学期、来源排课条目、教学任务、场地、周次、星期和节次,并建立面向教学任务/周次、课表/场地/周次的索引。
明细在“发布课表”的同一事务内生成;发布失败不会留下半成品。
2026-08-09 16:00:09 +08:00

91 lines
4.3 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
/// <inheritdoc />
public partial class PublishedTimetableOccurrences : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PublishedScheduleOccurrences",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false),
SchedulePlanId = table.Column<Guid>(type: "char(36)", nullable: false),
AcademicTermId = table.Column<Guid>(type: "char(36)", nullable: false),
ScheduleEntryId = table.Column<Guid>(type: "char(36)", nullable: false),
TeachingTaskId = table.Column<Guid>(type: "char(36)", nullable: false),
ClassroomId = table.Column<Guid>(type: "char(36)", nullable: true),
Week = table.Column<int>(type: "int", nullable: false),
DayOfWeek = table.Column<int>(type: "int", nullable: false),
StartPeriod = table.Column<int>(type: "int", nullable: false),
PeriodCount = table.Column<int>(type: "int", nullable: false),
Kind = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PublishedScheduleOccurrences", x => x.Id);
table.ForeignKey(
name: "FK_PublishedScheduleOccurrences_Classrooms_ClassroomId",
column: x => x.ClassroomId,
principalTable: "Classrooms",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_PublishedScheduleOccurrences_ScheduleEntries_ScheduleEntryId",
column: x => x.ScheduleEntryId,
principalTable: "ScheduleEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PublishedScheduleOccurrences_TeachingTasks_TeachingTaskId",
column: x => x.TeachingTaskId,
principalTable: "TeachingTasks",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_PublishedScheduleOccurrences_AcademicTermId_TeachingTaskId_W~",
table: "PublishedScheduleOccurrences",
columns: new[] { "AcademicTermId", "TeachingTaskId", "Week" });
migrationBuilder.CreateIndex(
name: "IX_PublishedScheduleOccurrences_ClassroomId",
table: "PublishedScheduleOccurrences",
column: "ClassroomId");
migrationBuilder.CreateIndex(
name: "IX_PublishedScheduleOccurrences_ScheduleEntryId_Week",
table: "PublishedScheduleOccurrences",
columns: new[] { "ScheduleEntryId", "Week" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_PublishedScheduleOccurrences_SchedulePlanId_ClassroomId_Week~",
table: "PublishedScheduleOccurrences",
columns: new[] { "SchedulePlanId", "ClassroomId", "Week", "DayOfWeek", "StartPeriod" });
migrationBuilder.CreateIndex(
name: "IX_PublishedScheduleOccurrences_TeachingTaskId",
table: "PublishedScheduleOccurrences",
column: "TeachingTaskId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PublishedScheduleOccurrences");
}
}
}