refactor: remove unused classroom fields

This commit is contained in:
2026-07-13 09:34:15 +08:00
parent a266d450e1
commit b9b295c997
14 changed files with 374 additions and 53 deletions

View File

@@ -14,6 +14,26 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
await this.backfillOrganizations();
await this.normalizeClassDates();
await this.protectAttendanceHistory();
await this.removeUnusedClassroomColumns();
}
private async removeUnusedClassroomColumns(): Promise<void> {
const runner = this.dataSource.createQueryRunner();
await runner.connect();
try {
const tables = await runner.getTables(['classrooms']);
if (tables.length === 0) return;
const table = await runner.getTable('classrooms');
const columnNames = new Set(table?.columns.map((column) => column.name) ?? []);
for (const columnName of ['course_type', 'supervisor']) {
if (columnNames.has(columnName)) {
await runner.query(`ALTER TABLE classrooms DROP COLUMN ${columnName}`);
}
}
} finally {
await runner.release();
}
}
private async ensureAiConfigTable(): Promise<void> {