Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit a16e9fb

Browse files
SORMAS-Foundation#2474 - Re-synchronize all contacts and epi data including locations
1 parent 6d186ae commit a16e9fb

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
127127
// name of the database file for your application. Stored in data/data/de.symeda.sormas.app/databases
128128
public static final String DATABASE_NAME = "sormas.db";
129129
// any time you make changes to your database objects, you may have to increase the database version
130-
public static final int DATABASE_VERSION = 211;
130+
public static final int DATABASE_VERSION = 212;
131131

132132
private static DatabaseHelper instance = null;
133133

@@ -1414,7 +1414,16 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int
14141414
getDao(EpiDataBurial.class).executeRaw("UPDATE epidataburial SET changeDate = 0 WHERE changeDate IS NOT NULL;");
14151415
getDao(EpiDataTravel.class).executeRaw("UPDATE epidatatravel SET changeDate = 0 WHERE changeDate IS NOT NULL;");
14161416
getDao(EpiDataGathering.class).executeRaw("UPDATE epidatagathering SET changeDate = 0 WHERE changeDate IS NOT NULL;");
1417-
1417+
case 211:
1418+
// Re-synchronize all contacts and epi data to prevent missing embedded entities
1419+
currentVersion = 211;
1420+
getDao(Sample.class).executeRaw("ALTER TABLE contacts ADD COLUMN epiData_id bigint REFERENCES epidata (id);");
1421+
getDao(Contact.class).executeRaw("UPDATE contacts SET changeDate = 0 WHERE changeDate IS NOT NULL;");
1422+
getDao(EpiData.class).executeRaw("UPDATE epidata SET changeDate = 0 WHERE changeDate IS NOT NULL;");
1423+
getDao(EpiDataBurial.class).executeRaw("UPDATE epidataburial SET changeDate = 0 WHERE changeDate IS NOT NULL;");
1424+
getDao(EpiDataTravel.class).executeRaw("UPDATE epidatatravel SET changeDate = 0 WHERE changeDate IS NOT NULL;");
1425+
getDao(EpiDataGathering.class).executeRaw("UPDATE epidatagathering SET changeDate = 0 WHERE changeDate IS NOT NULL;");
1426+
getDao(Location.class).executeRaw("UPDATE location SET changeDate = 0 WHERE changeDate IS NOT NULL;");
14181427

14191428
// ATTENTION: break should only be done after last version
14201429

0 commit comments

Comments
 (0)