调课
This commit is contained in:
@@ -953,6 +953,7 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
||||
entity.HasIndex(x => new { x.TeachingTaskId, x.Status });
|
||||
entity.HasIndex(x => x.ApplicantUserId);
|
||||
entity.HasIndex(x => new { x.Status, x.CreatedAt });
|
||||
entity.HasIndex(x => new { x.SourceScheduleEntryId, x.SourceWeek });
|
||||
entity.HasOne(x => x.TeachingTask).WithMany()
|
||||
.HasForeignKey(x => x.TeachingTaskId).OnDelete(DeleteBehavior.Restrict);
|
||||
entity.HasOne(x => x.Classroom).WithMany()
|
||||
|
||||
@@ -60,6 +60,8 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
"20260726_32_classroom_reservations";
|
||||
private const string BackgroundJobOutboxMigration =
|
||||
"20260726_33_background_job_outbox";
|
||||
private const string CourseAdjustmentOccurrencesMigration =
|
||||
"20260727_34_course_adjustment_occurrences";
|
||||
|
||||
public async Task MigrateAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
@@ -278,6 +280,21 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
courseAdjustmentsExist ? [] : CourseAdjustmentsStatements,
|
||||
cancellationToken);
|
||||
|
||||
var courseAdjustmentOccurrencesExist = await db.Database
|
||||
.SqlQueryRaw<int>(
|
||||
"""
|
||||
SELECT COUNT(*) AS "Value"
|
||||
FROM pragma_table_info('CourseAdjustments')
|
||||
WHERE name = 'SourceScheduleEntryId'
|
||||
""")
|
||||
.AnyAsync(value => value > 0, cancellationToken);
|
||||
await ApplyMigrationAsync(
|
||||
CourseAdjustmentOccurrencesMigration,
|
||||
courseAdjustmentOccurrencesExist
|
||||
? []
|
||||
: CourseAdjustmentOccurrencesStatements,
|
||||
cancellationToken);
|
||||
|
||||
var attendanceAppealExists = await db.Database
|
||||
.SqlQueryRaw<int>(
|
||||
"""
|
||||
@@ -1772,6 +1789,12 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
"Type" INTEGER NOT NULL,
|
||||
"Status" INTEGER NOT NULL,
|
||||
"ApplicantUserId" TEXT NOT NULL,
|
||||
"SourceScheduleEntryId" TEXT NULL,
|
||||
"SourceWeek" INTEGER NULL,
|
||||
"SourceDate" TEXT NULL,
|
||||
"SourceStartPeriod" INTEGER NULL,
|
||||
"SourcePeriodCount" INTEGER NULL,
|
||||
"SourceClassroomId" TEXT NULL,
|
||||
"TargetDate" TEXT NULL,
|
||||
"DayOfWeek" INTEGER NULL,
|
||||
"StartPeriod" INTEGER NULL,
|
||||
@@ -1817,6 +1840,17 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
"""CREATE INDEX "IX_Notifications_CreatedAt" ON "Notifications" ("CreatedAt");"""
|
||||
];
|
||||
|
||||
private static readonly string[] CourseAdjustmentOccurrencesStatements =
|
||||
[
|
||||
"""ALTER TABLE "CourseAdjustments" ADD "SourceScheduleEntryId" TEXT NULL;""",
|
||||
"""ALTER TABLE "CourseAdjustments" ADD "SourceWeek" INTEGER NULL;""",
|
||||
"""ALTER TABLE "CourseAdjustments" ADD "SourceDate" TEXT NULL;""",
|
||||
"""ALTER TABLE "CourseAdjustments" ADD "SourceStartPeriod" INTEGER NULL;""",
|
||||
"""ALTER TABLE "CourseAdjustments" ADD "SourcePeriodCount" INTEGER NULL;""",
|
||||
"""ALTER TABLE "CourseAdjustments" ADD "SourceClassroomId" TEXT NULL;""",
|
||||
"""CREATE INDEX "IX_CourseAdjustments_SourceScheduleEntryId_SourceWeek" ON "CourseAdjustments" ("SourceScheduleEntryId", "SourceWeek");"""
|
||||
];
|
||||
|
||||
private static readonly string[] AttendanceAppealStatements =
|
||||
[
|
||||
"""ALTER TABLE "AttendanceRecords" ADD COLUMN "AppealStatus" INTEGER NOT NULL DEFAULT 0;""",
|
||||
|
||||
+4867
File diff suppressed because it is too large
Load Diff
+88
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class CourseAdjustmentOccurrences : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "SourceClassroomId",
|
||||
table: "CourseAdjustments",
|
||||
type: "char(36)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "SourceDate",
|
||||
table: "CourseAdjustments",
|
||||
type: "date",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "SourcePeriodCount",
|
||||
table: "CourseAdjustments",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "SourceScheduleEntryId",
|
||||
table: "CourseAdjustments",
|
||||
type: "char(36)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "SourceStartPeriod",
|
||||
table: "CourseAdjustments",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "SourceWeek",
|
||||
table: "CourseAdjustments",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CourseAdjustments_SourceScheduleEntryId_SourceWeek",
|
||||
table: "CourseAdjustments",
|
||||
columns: new[] { "SourceScheduleEntryId", "SourceWeek" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_CourseAdjustments_SourceScheduleEntryId_SourceWeek",
|
||||
table: "CourseAdjustments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SourceClassroomId",
|
||||
table: "CourseAdjustments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SourceDate",
|
||||
table: "CourseAdjustments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SourcePeriodCount",
|
||||
table: "CourseAdjustments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SourceScheduleEntryId",
|
||||
table: "CourseAdjustments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SourceStartPeriod",
|
||||
table: "CourseAdjustments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SourceWeek",
|
||||
table: "CourseAdjustments");
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-2
@@ -714,6 +714,24 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
|
||||
b.Property<Guid?>("ReviewedByUserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("SourceClassroomId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime?>("SourceDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<int?>("SourcePeriodCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("SourceScheduleEntryId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int?>("SourceStartPeriod")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("SourceWeek")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("StartPeriod")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -746,6 +764,8 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
|
||||
|
||||
b.HasIndex("SubstituteTeacherId");
|
||||
|
||||
b.HasIndex("SourceScheduleEntryId", "SourceWeek");
|
||||
|
||||
b.HasIndex("Status", "CreatedAt");
|
||||
|
||||
b.HasIndex("TeachingTaskId", "Status");
|
||||
@@ -3473,10 +3493,10 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
|
||||
b.HasIndex("JobKind", "JobId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("State", "CreatedAt");
|
||||
|
||||
b.HasIndex("State", "CompletedAt");
|
||||
|
||||
b.HasIndex("State", "CreatedAt");
|
||||
|
||||
b.ToTable("BackgroundJobOutboxMessages");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user