refactor(rooms): remove dorm gender restrictions

This commit is contained in:
2026-07-13 15:19:09 +08:00
parent aa1ed7db56
commit f98c0ccaa8
12 changed files with 61 additions and 166 deletions

View File

@@ -15,6 +15,7 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
await this.normalizeClassDates();
await this.protectAttendanceHistory();
await this.removeUnusedClassroomColumns();
await this.removeUnusedRoomColumns();
await this.cleanupDepositRefundColumns();
await this.removeUnusedClassStudentColumns();
await this.normalizeClassroomStatuses();
@@ -39,6 +40,22 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
}
}
private async removeUnusedRoomColumns(): Promise<void> {
const runner = this.dataSource.createQueryRunner();
await runner.connect();
try {
const tables = await runner.getTables(['rooms']);
if (tables.length === 0) return;
const table = await runner.getTable('rooms');
if (table?.columns.some((column) => column.name === 'gender')) {
await runner.dropColumn('rooms', 'gender');
}
} finally {
await runner.release();
}
}
private async cleanupDepositRefundColumns(): Promise<void> {
const runner = this.dataSource.createQueryRunner();
await runner.connect();