Skip to content

Commit

Permalink
fixes after rebase for DB upgrade routine
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyScherzinger committed Apr 25, 2017
1 parent c3948e7 commit 913c3fc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/owncloud/android/datamodel/MediaFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* Business object representing a media folder with all information that are gathered via media queries.
*/
public class MediaFolder {
public static final Integer IMAGE = 0;
public static final Integer VIDEO = 1;
public static final Integer IMAGE_VIDEO = 2;
public static final Integer CUSTOM = 3;
public static final Integer CUSTOM = 0;
public static final Integer IMAGE = 1;
public static final Integer VIDEO = 2;
public static final Integer IMAGE_VIDEO = 3;

/** name of the folder. */
public String folderName;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class ProviderMeta {

public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 19;
public static final int DB_VERSION = 20;

private ProviderMeta() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,14 +888,17 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}

if (oldVersion < 18 && newVersion >= 18) {
Log_OC.i(SQL, "Entering in the #18 ADD in onUpgrade");
Log_OC.i(SQL, "Entering in the #18 Adding external link column to capabilities");
db.beginTransaction();
try {
// add type column default being IMAGE(0)
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE +
" INTEGER " + " DEFAULT 0");
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS +
" INTEGER " + " DEFAULT -1");

upgraded = true;
db.setTransactionSuccessful();
Expand All @@ -908,14 +911,11 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}

if (oldVersion < 18 && newVersion >= 18) {
Log_OC.i(SQL, "Adding external link column to capabilities");
if (oldVersion < 19 && newVersion >= 19) {
Log_OC.i(SQL, "Entering in the #19 Adding external link column to capabilities");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS +
" INTEGER " + " DEFAULT -1");

createExternalLinksTable(db);
upgraded = true;
db.setTransactionSuccessful();
} finally {
Expand All @@ -927,11 +927,15 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}

if (oldVersion < 19 && newVersion >= 19) {
Log_OC.i(SQL, "Adding external link column to capabilities");
if (oldVersion < 20 && newVersion >= 20) {
Log_OC.i(SQL, "Entering in the #20 ADD in onUpgrade");
db.beginTransaction();
try {
createExternalLinksTable(db);
// add type column default being IMAGE(0)
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE +
" INTEGER " + " DEFAULT 0");

upgraded = true;
db.setTransactionSuccessful();
} finally {
Expand Down

0 comments on commit 913c3fc

Please sign in to comment.