-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_database.py
More file actions
45 lines (39 loc) · 1.46 KB
/
Copy pathpatch_database.py
File metadata and controls
45 lines (39 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import re
with open("app/src/main/java/com/aistudio/unibuddy/qywvsp/data/Database.kt", "r") as f:
content = f.read()
# 1. Update version
content = re.sub(r'version = \d+', 'version = 13', content)
# 2. Add Professor entity and update AcademicRecord
old_academic_record = """data class AcademicRecord(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val pensumSubjectId: Int,
val grade: Double,
val status: AssessmentStatus,
val year: String,
val academicGroup: String
)"""
new_academic_record = """@Entity(tableName = "professors")
data class Professor(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val name: String,
val avatarSeed: String
)
@Entity(
tableName = "academic_records",
foreignKeys = [
ForeignKey(entity = PensumSubject::class, parentColumns = ["id"], childColumns = ["pensumSubjectId"], onDelete = ForeignKey.CASCADE),
ForeignKey(entity = Professor::class, parentColumns = ["id"], childColumns = ["professorId"], onDelete = ForeignKey.SET_NULL)
],
indices = [Index("pensumSubjectId"), Index("professorId")]
)
data class AcademicRecord(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val pensumSubjectId: Int,
val grade: Double,
val status: AssessmentStatus,
val year: String,
val academicGroup: String,
val professorId: Int? = null,
val rating: Int? = null
)"""
# In Database.kt, AcademicRecord already has the @Entity annotation. Let's find it carefully.