feat: add college archive fields
Some checks failed
CI 检查 / lint (pull_request) Has been cancelled
CI 检查 / typecheck (pull_request) Has been cancelled
CI 检查 / test (pull_request) Has been cancelled

This commit is contained in:
2026-07-21 15:35:35 +08:00
parent 2626d5f460
commit 37ef6f9dd7
11 changed files with 95 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
async onApplicationBootstrap(): Promise<void> {
await this.ensureAiConfigTable();
await this.ensureSyncStateLeaseColumns();
await this.ensureStudentProfileCollegeColumns();
await this.ensureCourseAttendanceSchema();
await this.ensureAttendanceDevicesSchema();
await this.ensureStudentWalletSchema();
@@ -42,6 +43,25 @@ export class DatabaseMigrationsService implements OnApplicationBootstrap {
}
}
private async ensureStudentProfileCollegeColumns(): Promise<void> {
const runner = this.dataSource.createQueryRunner();
await runner.connect();
try {
const table = await runner.getTable('student_profiles');
if (!table) return;
const columns = new Set(table.columns.map((column) => column.name));
const additions: Array<[string, string]> = [
['college_school', 'VARCHAR(100)'],
['college_major', 'VARCHAR(100)'],
];
for (const [name, definition] of additions) {
if (!columns.has(name)) await runner.query(`ALTER TABLE student_profiles ADD COLUMN ${name} ${definition}`);
}
} finally {
await runner.release();
}
}
private async ensureAttendanceDevicesSchema(): Promise<void> {
const runner = this.dataSource.createQueryRunner();
await runner.connect();