forked from github/wulkanowy-mirror
Fix exams sync (#108)
This commit is contained in:
parent
052d5e3911
commit
7d5072b529
@ -91,7 +91,7 @@ play {
|
|||||||
}
|
}
|
||||||
|
|
||||||
greendao {
|
greendao {
|
||||||
schemaVersion 26
|
schemaVersion 27
|
||||||
generateTests = true
|
generateTests = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import io.github.wulkanowy.api.Vulcan;
|
|||||||
import io.github.wulkanowy.data.db.dao.entities.DaoMaster;
|
import io.github.wulkanowy.data.db.dao.entities.DaoMaster;
|
||||||
import io.github.wulkanowy.data.db.dao.migrations.Migration23;
|
import io.github.wulkanowy.data.db.dao.migrations.Migration23;
|
||||||
import io.github.wulkanowy.data.db.dao.migrations.Migration26;
|
import io.github.wulkanowy.data.db.dao.migrations.Migration26;
|
||||||
|
import io.github.wulkanowy.data.db.dao.migrations.Migration27;
|
||||||
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
|
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
|
||||||
import io.github.wulkanowy.di.annotations.ApplicationContext;
|
import io.github.wulkanowy.di.annotations.ApplicationContext;
|
||||||
import io.github.wulkanowy.di.annotations.DatabaseInfo;
|
import io.github.wulkanowy.di.annotations.DatabaseInfo;
|
||||||
@ -76,6 +77,7 @@ public class DbHelper extends DaoMaster.OpenHelper {
|
|||||||
List<Migration> migrations = new ArrayList<>();
|
List<Migration> migrations = new ArrayList<>();
|
||||||
migrations.add(new Migration23());
|
migrations.add(new Migration23());
|
||||||
migrations.add(new Migration26());
|
migrations.add(new Migration26());
|
||||||
|
migrations.add(new Migration27());
|
||||||
|
|
||||||
// Sorting just to be safe, in case other people add migrations in the wrong order.
|
// Sorting just to be safe, in case other people add migrations in the wrong order.
|
||||||
Comparator<Migration> migrationComparator = new Comparator<Migration>() {
|
Comparator<Migration> migrationComparator = new Comparator<Migration>() {
|
||||||
|
@ -4,13 +4,15 @@ import org.greenrobot.greendao.DaoException;
|
|||||||
import org.greenrobot.greendao.annotation.Entity;
|
import org.greenrobot.greendao.annotation.Entity;
|
||||||
import org.greenrobot.greendao.annotation.Generated;
|
import org.greenrobot.greendao.annotation.Generated;
|
||||||
import org.greenrobot.greendao.annotation.Id;
|
import org.greenrobot.greendao.annotation.Id;
|
||||||
|
import org.greenrobot.greendao.annotation.Index;
|
||||||
import org.greenrobot.greendao.annotation.Property;
|
import org.greenrobot.greendao.annotation.Property;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Entity(
|
@Entity(
|
||||||
nameInDb = "Exams",
|
nameInDb = "Exams",
|
||||||
active = true
|
active = true,
|
||||||
|
indexes = {@Index(value = "dayId,entryDate,subjectAndGroup,type,teacher", unique = true)}
|
||||||
)
|
)
|
||||||
|
|
||||||
public class Exam implements Serializable {
|
public class Exam implements Serializable {
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package io.github.wulkanowy.data.db.dao.migrations;
|
||||||
|
|
||||||
|
import org.greenrobot.greendao.database.Database;
|
||||||
|
|
||||||
|
import io.github.wulkanowy.api.Vulcan;
|
||||||
|
import io.github.wulkanowy.data.db.dao.DbHelper;
|
||||||
|
import io.github.wulkanowy.data.db.dao.entities.ExamDao;
|
||||||
|
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
|
||||||
|
|
||||||
|
public class Migration27 implements DbHelper.Migration {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getVersion() {
|
||||||
|
return 27;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runMigration(Database db, SharedPrefContract sharedPref, Vulcan vulcan) throws Exception {
|
||||||
|
ExamDao.dropTable(db, true);
|
||||||
|
ExamDao.createTable(db, true);
|
||||||
|
|
||||||
|
db.execSQL("UPDATE Weeks SET exams_synced = 0");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user