refactor(classes): preserve student membership history
This commit is contained in:
@@ -16,6 +16,7 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
|
||||
await this.protectAttendanceHistory();
|
||||
await this.removeUnusedClassroomColumns();
|
||||
await this.cleanupDepositRefundColumns();
|
||||
await this.removeUnusedClassStudentColumns();
|
||||
}
|
||||
|
||||
private async removeUnusedClassroomColumns(): Promise<void> {
|
||||
@@ -75,6 +76,22 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
|
||||
}
|
||||
}
|
||||
|
||||
private async removeUnusedClassStudentColumns(): Promise<void> {
|
||||
const runner = this.dataSource.createQueryRunner();
|
||||
await runner.connect();
|
||||
try {
|
||||
const tables = await runner.getTables(['class_student']);
|
||||
if (tables.length === 0) return;
|
||||
|
||||
const table = await runner.getTable('class_student');
|
||||
if (table?.columns.some((column) => column.name === 'enrollment_id')) {
|
||||
await runner.dropColumn('class_student', 'enrollment_id');
|
||||
}
|
||||
} finally {
|
||||
await runner.release();
|
||||
}
|
||||
}
|
||||
|
||||
private async ensureAiConfigTable(): Promise<void> {
|
||||
const runner = this.dataSource.createQueryRunner();
|
||||
await runner.connect();
|
||||
|
||||
Reference in New Issue
Block a user