refactor: remove unused classroom fields
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user