]> git.ktnx.net Git - mobile-ledger.git/commitdiff
store profile API version in the database
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 21 Dec 2019 21:24:16 +0000 (23:24 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 21 Dec 2019 21:24:16 +0000 (23:24 +0200)
app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java
app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java
app/src/main/res/raw/sql_24.sql [new file with mode: 0644]

index 2cd159c5e7079c840e333f56da1e5c0c6eaf99a8..1f2eac7360acc17e5356fa39387363297cc24d63 100644 (file)
@@ -82,8 +82,8 @@ public final class MobileLedgerProfile {
         SQLiteDatabase db = App.getDatabase();
         try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
                                          "auth_password, permit_posting, theme, order_no, " +
         SQLiteDatabase db = App.getDatabase();
         try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
                                          "auth_password, permit_posting, theme, order_no, " +
-                                         "preferred_accounts_filter, future_dates FROM " +
-                                         "profiles order by order_no", null))
+                                         "preferred_accounts_filter, future_dates, api_version " +
+                                         "FROM " + "profiles order by order_no", null))
         {
             while (cursor.moveToNext()) {
                 MobileLedgerProfile item = new MobileLedgerProfile(cursor.getString(0));
         {
             while (cursor.moveToNext()) {
                 MobileLedgerProfile item = new MobileLedgerProfile(cursor.getString(0));
@@ -97,6 +97,7 @@ public final class MobileLedgerProfile {
                 item.orderNo = cursor.getInt(8);
                 item.setPreferredAccountsFilter(cursor.getString(9));
                 item.setFutureDates(cursor.getInt(10));
                 item.orderNo = cursor.getInt(8);
                 item.setPreferredAccountsFilter(cursor.getString(9));
                 item.setFutureDates(cursor.getInt(10));
+                item.setApiVersion(cursor.getInt(11));
                 list.add(item);
                 if (item.getUuid()
                         .equals(currentProfileUUID))
                 list.add(item);
                 if (item.getUuid()
                         .equals(currentProfileUUID))
@@ -211,12 +212,12 @@ public final class MobileLedgerProfile {
 //                    permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
             db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
                        "use_authentication, auth_user, " +
 //                    permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
             db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
                        "use_authentication, auth_user, " +
-                       "auth_password, theme, order_no, preferred_accounts_filter, future_dates) " +
-                       "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+                       "auth_password, theme, order_no, preferred_accounts_filter, future_dates, " +
+                       "api_version) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
                     new Object[]{uuid, name, permitPosting, url, authEnabled,
                                  authEnabled ? authUserName : null,
                                  authEnabled ? authPassword : null, themeId, orderNo,
                     new Object[]{uuid, name, permitPosting, url, authEnabled,
                                  authEnabled ? authUserName : null,
                                  authEnabled ? authPassword : null, themeId, orderNo,
-                                 preferredAccountsFilter, futureDates.toInt()
+                                 preferredAccountsFilter, futureDates.toInt(), apiVersion.toInt()
                     });
             db.setTransactionSuccessful();
         }
                     });
             db.setTransactionSuccessful();
         }
index df39ea1a3f4c5bd857845be16098ea5235e37558..9d841ea62035490edd15e325693fe38bae878b4a 100644 (file)
@@ -34,7 +34,7 @@ import static net.ktnx.mobileledger.utils.Logger.debug;
 
 public class MobileLedgerDatabase extends SQLiteOpenHelper {
     private static final String DB_NAME = "MoLe.db";
 
 public class MobileLedgerDatabase extends SQLiteOpenHelper {
     private static final String DB_NAME = "MoLe.db";
-    private static final int LATEST_REVISION = 23;
+    private static final int LATEST_REVISION = 24;
     private static final String CREATE_DB_SQL = "create_db";
 
     private final Application mContext;
     private static final String CREATE_DB_SQL = "create_db";
 
     private final Application mContext;
diff --git a/app/src/main/res/raw/sql_24.sql b/app/src/main/res/raw/sql_24.sql
new file mode 100644 (file)
index 0000000..84ed1ae
--- /dev/null
@@ -0,0 +1 @@
+alter table profiles add api_version integer;
\ No newline at end of file