Browse Source

re-add user theming columns if they do not exist yet

tobiaskaminsky 7 years ago
parent
commit
8a21a1ad21

+ 1 - 1
src/main/java/com/owncloud/android/db/ProviderMeta.java

@@ -32,7 +32,7 @@ import com.owncloud.android.MainApp;
 public class ProviderMeta {
 
     public static final String DB_NAME = "filelist";
-    public static final int DB_VERSION = 23;
+    public static final int DB_VERSION = 24;
 
     private ProviderMeta() {
     }

+ 39 - 0
src/main/java/com/owncloud/android/providers/FileContentProvider.java

@@ -1111,6 +1111,45 @@ public class FileContentProvider extends ContentProvider {
                 if (!upgraded) {
                     Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
                 }
+
+                if (oldVersion < 24 && newVersion >= 24) {
+                    Log_OC.i(SQL, "Entering in the #24 Re-adding user theming to capabilities table");
+                    db.beginTransaction();
+                    try {
+                        if (!checkIfColumnExists(db, ProviderTableMeta.CAPABILITIES_TABLE_NAME,
+                                ProviderTableMeta.CAPABILITIES_SERVER_NAME)) {
+                            db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+                                    ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_NAME + " TEXT ");
+                        }
+
+                        if (!checkIfColumnExists(db, ProviderTableMeta.CAPABILITIES_TABLE_NAME,
+                                ProviderTableMeta.CAPABILITIES_SERVER_COLOR)) {
+                            db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+                                    ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_COLOR + " TEXT ");
+                        }
+
+                        if (!checkIfColumnExists(db, ProviderTableMeta.CAPABILITIES_TABLE_NAME,
+                                ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL)) {
+                            db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+                                    ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL + " TEXT ");
+                        }
+
+                        if (!checkIfColumnExists(db, ProviderTableMeta.CAPABILITIES_TABLE_NAME,
+                                ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN)) {
+                            db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+                                    ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN + " TEXT ");
+                        }
+
+                        upgraded = true;
+                        db.setTransactionSuccessful();
+                    } finally {
+                        db.endTransaction();
+                    }
+                }
+
+                if (!upgraded) {
+                    Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+                }
             }
         }
     }