Skip to content

Commit

Permalink
🐛 Add migration to update visit pre_processed values
Browse files Browse the repository at this point in the history
  • Loading branch information
allan-on committed May 24, 2022
1 parent 5b4fb62 commit 948abfb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public interface RepositoryUtils {
"having count(*) > 1 " +
")";

String UPDATE_NULL_VISIT_PRE_PROCESSED_JSON_SQL= "UPDATE visits SET pre_processed = visit_json " +
"WHERE pre_processed IS NULL AND processed = 0";

static void addDetailsColumnToFamilySearchTable(SQLiteDatabase db) {
try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,16 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 15:
upgradeToVersion15(db);
break;
case 16:
upgradeToVersion16(db);
break;
default:
break;
}
upgradeTo++;
}
}

private static void upgradeToVersion15(SQLiteDatabase db) {
try {
// add new column
db.execSQL("ALTER TABLE ec_family_member ADD COLUMN marital_status VARCHAR;");
} catch (Exception e) {
Timber.e(e, "upgradeToVersion15");
}
}

private static void upgradeToVersion14(SQLiteDatabase db) {
try {
// form configuration
ClientFormRepository.createTable(db);
ManifestRepository.createTable(db);
} catch (Exception e) {
Timber.e(e, "upgradeToVersion14");
}
}


private static void upgradeToVersion2(SQLiteDatabase db) {
try {
Expand Down Expand Up @@ -172,6 +156,29 @@ private static void upgradeToVersion8(SQLiteDatabase db) {
}
}

private static void upgradeToVersion10(SQLiteDatabase db, int oldDbVersion) {
try {
ReportingLibrary reportingLibraryInstance = ReportingLibrary.getInstance();
if (oldDbVersion == 9) {
reportingLibraryInstance.truncateIndicatorDefinitionTables(db);
}
initializeIndicatorDefinitions(reportingLibraryInstance, db);
} catch (Exception e) {
Timber.e(e);
}
}

private static void upgradeToVersion11(Context context, SQLiteDatabase db) {
try {
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL);
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX);

IMDatabaseUtils.accessAssetsAndFillDataBaseForVaccineTypes(context, db);
} catch (Exception e) {
Timber.e(e);
}
}

private static void upgradeToVersion12(SQLiteDatabase db) {
try {
db.execSQL(VisitRepository.ADD_VISIT_GROUP_COLUMN);
Expand All @@ -190,26 +197,30 @@ private static void upgradeToVersion13(SQLiteDatabase db) {
}
}

private static void upgradeToVersion10(SQLiteDatabase db, int oldDbVersion) {
private static void upgradeToVersion14(SQLiteDatabase db) {
try {
ReportingLibrary reportingLibraryInstance = ReportingLibrary.getInstance();
if (oldDbVersion == 9) {
reportingLibraryInstance.truncateIndicatorDefinitionTables(db);
}
initializeIndicatorDefinitions(reportingLibraryInstance, db);
// form configuration
ClientFormRepository.createTable(db);
ManifestRepository.createTable(db);
} catch (Exception e) {
Timber.e(e);
Timber.e(e, "upgradeToVersion14");
}
}

private static void upgradeToVersion11(Context context, SQLiteDatabase db) {
private static void upgradeToVersion15(SQLiteDatabase db) {
try {
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL);
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX);
// add new column
db.execSQL("ALTER TABLE ec_family_member ADD COLUMN marital_status VARCHAR;");
} catch (Exception e) {
Timber.e(e, "upgradeToVersion15");
}
}

IMDatabaseUtils.accessAssetsAndFillDataBaseForVaccineTypes(context, db);
private static void upgradeToVersion16(SQLiteDatabase db) {
try {
db.execSQL(RepositoryUtils.UPDATE_NULL_VISIT_PRE_PROCESSED_JSON_SQL);
} catch (Exception e) {
Timber.e(e);
Timber.e(e, "Error upgrading to Version16");
}
}

Expand Down

0 comments on commit 948abfb

Please sign in to comment.