mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-06-22 01:53:04 +02:00
[APIv2/Librus] Fix announcements duplicate ids (migrate from crc16 to crc32)
This commit is contained in:
@ -108,7 +108,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date;
|
||||
AttendanceType.class,
|
||||
pl.szczodrzynski.edziennik.data.db.modules.timetable.Lesson.class,
|
||||
ConfigEntry.class,
|
||||
Metadata.class}, version = 67)
|
||||
Metadata.class}, version = 68)
|
||||
@TypeConverters({
|
||||
ConverterTime.class,
|
||||
ConverterDate.class,
|
||||
@ -815,6 +815,14 @@ public abstract class AppDb extends RoomDatabase {
|
||||
database.execSQL("DROP TABLE _gradeCategories");
|
||||
}
|
||||
};
|
||||
private static final Migration MIGRATION_67_68 = new Migration(67, 68) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
/* Migration from crc16 to crc32 id */
|
||||
database.execSQL("DELETE FROM announcements");
|
||||
database.execSQL("DELETE FROM metadata WHERE thingType=7");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static AppDb getDatabase(final Context context) {
|
||||
@ -879,7 +887,8 @@ public abstract class AppDb extends RoomDatabase {
|
||||
MIGRATION_63_64,
|
||||
MIGRATION_64_65,
|
||||
MIGRATION_65_66,
|
||||
MIGRATION_66_67
|
||||
MIGRATION_66_67,
|
||||
MIGRATION_67_68
|
||||
)
|
||||
.allowMainThreadQueries()
|
||||
//.fallbackToDestructiveMigration()
|
||||
|
@ -36,7 +36,7 @@ public abstract class AnnouncementDao {
|
||||
"LEFT JOIN teachers USING(profileId, teacherId)\n" +
|
||||
"LEFT JOIN metadata ON announcementId = thingId AND thingType = "+TYPE_ANNOUNCEMENT+" AND metadata.profileId = "+profileId+"\n" +
|
||||
"WHERE announcements.profileId = "+profileId+" AND "+filter+"\n" +
|
||||
"ORDER BY announcementStartDate DESC"));
|
||||
"ORDER BY addedDate DESC"));
|
||||
}
|
||||
public LiveData<List<AnnouncementFull>> getAll(int profileId) {
|
||||
return getAll(profileId, "1");
|
||||
@ -55,7 +55,7 @@ public abstract class AnnouncementDao {
|
||||
"LEFT JOIN teachers USING(profileId, teacherId)\n" +
|
||||
"LEFT JOIN metadata ON announcementId = thingId AND thingType = "+TYPE_ANNOUNCEMENT+" AND metadata.profileId = "+profileId+"\n" +
|
||||
"WHERE announcements.profileId = "+profileId+" AND "+filter+"\n" +
|
||||
"ORDER BY announcementStartDate DESC"));
|
||||
"ORDER BY addedDate DESC"));
|
||||
}
|
||||
public List<AnnouncementFull> getNotNotifiedNow(int profileId) {
|
||||
return getAllNow(profileId, "notified = 0");
|
||||
|
Reference in New Issue
Block a user