Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #485 from a93h/master
Browse files Browse the repository at this point in the history
Fix Upgrade Code
  • Loading branch information
Austin H authored Aug 28, 2019
2 parents f82a29c + 4765ee3 commit baf5339
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/adam/aslfms/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (settings.getWhatsNewViewedVersion() < v) {
new WhatsNewDialog(this).show();
settings.setWhatsNewViewedVersion(v);
mDb.alterDataBaseOnce(); // version 1.5.8 only!
mDb.alterDataBaseOnce(); // TODO: VERSION 1.5.8 only!
}

// Start listening service if applicable
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/java/com/adam/aslfms/util/ScrobblesDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,14 +508,22 @@ public CorrectionRule fetchCorrectioneRule(int id) {

public void alterDataBaseOnce(){
try {
mDb.execSQL("ALTER TABLE " + TABLENAME_SCROBBLES + " ADD COLUMN albumartist text");
try {
mDb.execSQL("SELECT trackartist FROM " + TABLENAME_SCROBBLES); // check if table column exists
} catch (Exception e){
mDb.execSQL("ALTER TABLE " + TABLENAME_SCROBBLES + " ADD COLUMN trackartist text DEFAULT '' not null"); // if column not exists create column
}
} catch (Exception ignore) {
// may capture already exists albumartist
// may capture already exists trackartist
}
try {
mDb.execSQL("ALTER TABLE " + TABLENAME_SCROBBLES + " ADD COLUMN trackartist text");
try {
mDb.execSQL("SELECT albumartist FROM " + TABLENAME_SCROBBLES); // check if table column exists
} catch (Exception e){
mDb.execSQL("ALTER TABLE " + TABLENAME_SCROBBLES + " ADD COLUMN albumartist text DEFAULT '' not null"); // if column not exists create column
}
} catch (Exception ignore) {
// may capture already exists trackartist
// may capture already exists albumartist
}
}
}

0 comments on commit baf5339

Please sign in to comment.