[APIv2/DB] Add profile account name, class, school year fields.

This commit is contained in:
Kuba Szczodrzyński
2019-10-27 18:03:58 +01:00
parent 10c439afad
commit 054426c9cc
3 changed files with 39 additions and 4 deletions

View File

@ -103,7 +103,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date;
Classroom.class,
NoticeType.class,
AttendanceType.class,
Metadata.class}, version = 62)
Metadata.class}, version = 63)
@TypeConverters({
ConverterTime.class,
ConverterDate.class,
@ -721,6 +721,14 @@ public abstract class AppDb extends RoomDatabase {
")");
}
};
private static final Migration MIGRATION_62_63 = new Migration(62, 63) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE profiles ADD COLUMN accountNameLong TEXT DEFAULT NULL");
database.execSQL("ALTER TABLE profiles ADD COLUMN studentClassName TEXT DEFAULT NULL");
database.execSQL("ALTER TABLE profiles ADD COLUMN studentSchoolYear TEXT DEFAULT NULL");
}
};
public static AppDb getDatabase(final Context context) {
@ -780,7 +788,8 @@ public abstract class AppDb extends RoomDatabase {
MIGRATION_58_59,
MIGRATION_59_60,
MIGRATION_60_61,
MIGRATION_61_62
MIGRATION_61_62,
MIGRATION_62_63
)
.allowMainThreadQueries()
//.fallbackToDestructiveMigration()

View File

@ -56,9 +56,11 @@ open class Profile : IDrawerProfile {
* If null, then it's a student account.
* If not null, then it's a parent account with this name.
*/
@Ignore
var accountNameLong: String? = null
var studentClassName: String? = null
var studentSchoolYear: String? = null
var registration = REGISTRATION_UNSPECIFIED
var gradeColorMode = COLOR_MODE_WEIGHTED