]> git.ktnx.net Git - mobile-ledger.git/commitdiff
describe profiles for Room
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 20:26:02 +0000 (22:26 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 20:26:02 +0000 (22:26 +0200)
app/schemas/net.ktnx.mobileledger.db.DB/58.json [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/db/DB.java
app/src/main/java/net/ktnx/mobileledger/db/Profile.java [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java
app/src/main/res/raw/create_db.sql
app/src/main/res/raw/sql_58.sql [new file with mode: 0644]

diff --git a/app/schemas/net.ktnx.mobileledger.db.DB/58.json b/app/schemas/net.ktnx.mobileledger.db.DB/58.json
new file mode 100644 (file)
index 0000000..fca6744
--- /dev/null
@@ -0,0 +1,472 @@
+{
+  "formatVersion": 1,
+  "database": {
+    "version": 58,
+    "identityHash": "ba63bc73720c33314f20ec5312984ab4",
+    "entities": [
+      {
+        "tableName": "templates",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `regular_expression` TEXT NOT NULL, `test_text` TEXT, `transaction_description` TEXT, `transaction_description_match_group` INTEGER, `transaction_comment` TEXT, `transaction_comment_match_group` INTEGER, `date_year` INTEGER, `date_year_match_group` INTEGER, `date_month` INTEGER, `date_month_match_group` INTEGER, `date_day` INTEGER, `date_day_match_group` INTEGER, `is_fallback` INTEGER NOT NULL)",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "regularExpression",
+            "columnName": "regular_expression",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "testText",
+            "columnName": "test_text",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionDescription",
+            "columnName": "transaction_description",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionDescriptionMatchGroup",
+            "columnName": "transaction_description_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionComment",
+            "columnName": "transaction_comment",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionCommentMatchGroup",
+            "columnName": "transaction_comment_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateYear",
+            "columnName": "date_year",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateYearMatchGroup",
+            "columnName": "date_year_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateMonth",
+            "columnName": "date_month",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateMonthMatchGroup",
+            "columnName": "date_month_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateDay",
+            "columnName": "date_day",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateDayMatchGroup",
+            "columnName": "date_day_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "isFallback",
+            "columnName": "is_fallback",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": []
+      },
+      {
+        "tableName": "template_accounts",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `template_id` INTEGER NOT NULL, `acc` TEXT, `position` INTEGER NOT NULL, `acc_match_group` INTEGER, `currency` INTEGER, `currency_match_group` INTEGER, `amount` REAL, `amount_match_group` INTEGER, `comment` TEXT, `comment_match_group` INTEGER, `negate_amount` INTEGER, FOREIGN KEY(`template_id`) REFERENCES `templates`(`id`) ON UPDATE RESTRICT ON DELETE CASCADE , FOREIGN KEY(`currency`) REFERENCES `currencies`(`id`) ON UPDATE RESTRICT ON DELETE RESTRICT )",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "templateId",
+            "columnName": "template_id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "accountName",
+            "columnName": "acc",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "position",
+            "columnName": "position",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "accountNameMatchGroup",
+            "columnName": "acc_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "currency",
+            "columnName": "currency",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "currencyMatchGroup",
+            "columnName": "currency_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "amount",
+            "columnName": "amount",
+            "affinity": "REAL",
+            "notNull": false
+          },
+          {
+            "fieldPath": "amountMatchGroup",
+            "columnName": "amount_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "accountComment",
+            "columnName": "comment",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "accountCommentMatchGroup",
+            "columnName": "comment_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "negateAmount",
+            "columnName": "negate_amount",
+            "affinity": "INTEGER",
+            "notNull": false
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [
+          {
+            "name": "fk_template_accounts_template",
+            "unique": false,
+            "columnNames": [
+              "template_id"
+            ],
+            "createSql": "CREATE INDEX IF NOT EXISTS `fk_template_accounts_template` ON `${TABLE_NAME}` (`template_id`)"
+          },
+          {
+            "name": "fk_template_accounts_currency",
+            "unique": false,
+            "columnNames": [
+              "currency"
+            ],
+            "createSql": "CREATE INDEX IF NOT EXISTS `fk_template_accounts_currency` ON `${TABLE_NAME}` (`currency`)"
+          }
+        ],
+        "foreignKeys": [
+          {
+            "table": "templates",
+            "onDelete": "CASCADE",
+            "onUpdate": "RESTRICT",
+            "columns": [
+              "template_id"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          },
+          {
+            "table": "currencies",
+            "onDelete": "RESTRICT",
+            "onUpdate": "RESTRICT",
+            "columns": [
+              "currency"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          }
+        ]
+      },
+      {
+        "tableName": "currencies",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `position` TEXT NOT NULL, `has_gap` INTEGER NOT NULL)",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "position",
+            "columnName": "position",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "hasGap",
+            "columnName": "has_gap",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": []
+      },
+      {
+        "tableName": "accounts",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`level` INTEGER NOT NULL, `profile` TEXT NOT NULL, `name` TEXT NOT NULL, `name_upper` TEXT NOT NULL, `parent_name` TEXT, `expanded` INTEGER NOT NULL DEFAULT 1, `amounts_expanded` INTEGER NOT NULL DEFAULT 0, `generation` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`profile`, `name`))",
+        "fields": [
+          {
+            "fieldPath": "level",
+            "columnName": "level",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "profile",
+            "columnName": "profile",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "nameUpper",
+            "columnName": "name_upper",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "parentName",
+            "columnName": "parent_name",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "expanded",
+            "columnName": "expanded",
+            "affinity": "INTEGER",
+            "notNull": true,
+            "defaultValue": "1"
+          },
+          {
+            "fieldPath": "amountsExpanded",
+            "columnName": "amounts_expanded",
+            "affinity": "INTEGER",
+            "notNull": true,
+            "defaultValue": "0"
+          },
+          {
+            "fieldPath": "generation",
+            "columnName": "generation",
+            "affinity": "INTEGER",
+            "notNull": true,
+            "defaultValue": "0"
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "profile",
+            "name"
+          ],
+          "autoGenerate": false
+        },
+        "indices": [],
+        "foreignKeys": []
+      },
+      {
+        "tableName": "profiles",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uuid` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `use_authentication` INTEGER NOT NULL, `auth_user` TEXT, `auth_password` TEXT, `order_no` INTEGER NOT NULL, `permit_posting` INTEGER NOT NULL, `theme` INTEGER NOT NULL DEFAULT -1, `preferred_accounts_filter` TEXT, `future_dates` INTEGER NOT NULL, `api_version` INTEGER NOT NULL, `show_commodity_by_default` INTEGER NOT NULL, `default_commodity` TEXT, `show_comments_by_default` INTEGER NOT NULL DEFAULT 1, `detected_version_pre_1_19` INTEGER NOT NULL, `detected_version_major` INTEGER NOT NULL, `detected_version_minor` INTEGER NOT NULL, PRIMARY KEY(`uuid`))",
+        "fields": [
+          {
+            "fieldPath": "uuid",
+            "columnName": "uuid",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "url",
+            "columnName": "url",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "useAuthentication",
+            "columnName": "use_authentication",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "authUser",
+            "columnName": "auth_user",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "authPassword",
+            "columnName": "auth_password",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "orderNo",
+            "columnName": "order_no",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "permitPosting",
+            "columnName": "permit_posting",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "theme",
+            "columnName": "theme",
+            "affinity": "INTEGER",
+            "notNull": true,
+            "defaultValue": "-1"
+          },
+          {
+            "fieldPath": "preferredAccountsFilter",
+            "columnName": "preferred_accounts_filter",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "futureDates",
+            "columnName": "future_dates",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "apiVersion",
+            "columnName": "api_version",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "showCommodityByDefault",
+            "columnName": "show_commodity_by_default",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "defaultCommodity",
+            "columnName": "default_commodity",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "showCommentsByDefault",
+            "columnName": "show_comments_by_default",
+            "affinity": "INTEGER",
+            "notNull": true,
+            "defaultValue": "1"
+          },
+          {
+            "fieldPath": "detectedVersionPre_1_19",
+            "columnName": "detected_version_pre_1_19",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "detectedVersionMajor",
+            "columnName": "detected_version_major",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "detectedVersionMinor",
+            "columnName": "detected_version_minor",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "uuid"
+          ],
+          "autoGenerate": false
+        },
+        "indices": [],
+        "foreignKeys": []
+      }
+    ],
+    "views": [],
+    "setupQueries": [
+      "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ba63bc73720c33314f20ec5312984ab4')"
+    ]
+  }
+}
\ No newline at end of file
index 2887cc5160b59cd14962bf7a1675c45815324218..dadf9b8a155a0754f178bf122c5fda08ab3316fc 100644 (file)
@@ -31,8 +31,9 @@ import net.ktnx.mobileledger.dao.TemplateAccountDAO;
 import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
 import net.ktnx.mobileledger.utils.MobileLedgerDatabase;
 
-@Database(version = 57,
-          entities = {TemplateHeader.class, TemplateAccount.class, Currency.class, Account.class
+@Database(version = 58,
+          entities = {TemplateHeader.class, TemplateAccount.class, Currency.class, Account.class,
+                      Profile.class
           })
 abstract public class DB extends RoomDatabase {
     private static DB instance;
diff --git a/app/src/main/java/net/ktnx/mobileledger/db/Profile.java b/app/src/main/java/net/ktnx/mobileledger/db/Profile.java
new file mode 100644 (file)
index 0000000..1ed8a21
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.db;
+
+import androidx.annotation.NonNull;
+import androidx.room.ColumnInfo;
+import androidx.room.Entity;
+
+/*
+ create table profiles(uuid varchar not null primary key, name not null, url not null,
+ use_authentication boolean not null, auth_user varchar, auth_password varchar, order_no
+ integer, permit_posting boolean default 0, theme integer default -1, preferred_accounts_filter
+ varchar, future_dates integer, api_version integer, show_commodity_by_default boolean default
+ 0, default_commodity varchar, show_comments_by_default boolean default 1,
+ detected_version_pre_1_19 boolean, detected_version_major integer, detected_version_minor
+ integer);
+*/
+@Entity(tableName = "profiles", primaryKeys = {"uuid"})
+public class Profile {
+    @NonNull
+    @ColumnInfo
+    private String uuid = "invalid";
+    @NonNull
+    @ColumnInfo
+    private String name = "";
+    @NonNull
+    @ColumnInfo
+    private String url = "";
+    @ColumnInfo(name = "use_authentication")
+    private boolean useAuthentication;
+    @ColumnInfo(name = "auth_user")
+    private String authUser;
+    @ColumnInfo(name = "auth_password")
+    private String authPassword;
+    @ColumnInfo(name = "order_no")
+    private int orderNo;
+    @ColumnInfo(name = "permit_posting")
+    private boolean permitPosting;
+    @ColumnInfo(defaultValue = "-1")
+    private int theme = -1;
+    @ColumnInfo(name = "preferred_accounts_filter")
+    private String preferredAccountsFilter;
+    @ColumnInfo(name = "future_dates")
+    private int futureDates;
+    @ColumnInfo(name = "api_version")
+    private int apiVersion;
+    @ColumnInfo(name = "show_commodity_by_default")
+    private boolean showCommodityByDefault;
+    @ColumnInfo(name = "default_commodity")
+    private String defaultCommodity;
+    @ColumnInfo(name = "show_comments_by_default", defaultValue = "1")
+    private boolean showCommentsByDefault = true;
+    @ColumnInfo(name = "detected_version_pre_1_19")
+    private boolean detectedVersionPre_1_19;
+    @ColumnInfo(name = "detected_version_major")
+    private int detectedVersionMajor;
+    @ColumnInfo(name = "detected_version_minor")
+    private int detectedVersionMinor;
+    @NonNull
+    public String getUuid() {
+        return uuid;
+    }
+    public void setUuid(@NonNull String uuid) {
+        this.uuid = uuid;
+    }
+    @NonNull
+    public String getName() {
+        return name;
+    }
+    public void setName(@NonNull String name) {
+        this.name = name;
+    }
+    @NonNull
+    public String getUrl() {
+        return url;
+    }
+    public void setUrl(@NonNull String url) {
+        this.url = url;
+    }
+    public boolean useAuthentication() {
+        return useAuthentication;
+    }
+    public void setUseAuthentication(boolean useAuthentication) {
+        this.useAuthentication = useAuthentication;
+    }
+    public String getAuthUser() {
+        return authUser;
+    }
+    public void setAuthUser(String authUser) {
+        this.authUser = authUser;
+    }
+    public String getAuthPassword() {
+        return authPassword;
+    }
+    public void setAuthPassword(String authPassword) {
+        this.authPassword = authPassword;
+    }
+    public int getOrderNo() {
+        return orderNo;
+    }
+    public void setOrderNo(int orderNo) {
+        this.orderNo = orderNo;
+    }
+    public boolean permitPosting() {
+        return permitPosting;
+    }
+    public void setPermitPosting(boolean permitPosting) {
+        this.permitPosting = permitPosting;
+    }
+    public int getTheme() {
+        return theme;
+    }
+    public void setTheme(int theme) {
+        this.theme = theme;
+    }
+    public String getPreferredAccountsFilter() {
+        return preferredAccountsFilter;
+    }
+    public void setPreferredAccountsFilter(String preferredAccountsFilter) {
+        this.preferredAccountsFilter = preferredAccountsFilter;
+    }
+    public int getFutureDates() {
+        return futureDates;
+    }
+    public void setFutureDates(int futureDates) {
+        this.futureDates = futureDates;
+    }
+    public int getApiVersion() {
+        return apiVersion;
+    }
+    public void setApiVersion(int apiVersion) {
+        this.apiVersion = apiVersion;
+    }
+    public boolean getShowCommodityByDefault() {
+        return showCommodityByDefault;
+    }
+    public void setShowCommodityByDefault(boolean showCommodityByDefault) {
+        this.showCommodityByDefault = showCommodityByDefault;
+    }
+    public String getDefaultCommodity() {
+        return defaultCommodity;
+    }
+    public void setDefaultCommodity(String defaultCommodity) {
+        this.defaultCommodity = defaultCommodity;
+    }
+    public boolean getShowCommentsByDefault() {
+        return showCommentsByDefault;
+    }
+    public void setShowCommentsByDefault(boolean showCommentsByDefault) {
+        this.showCommentsByDefault = showCommentsByDefault;
+    }
+    public boolean detectedVersionPre_1_19() {
+        return detectedVersionPre_1_19;
+    }
+    public void setDetectedVersionPre_1_19(boolean detectedVersionPre_1_19) {
+        this.detectedVersionPre_1_19 = detectedVersionPre_1_19;
+    }
+    public int getDetectedVersionMajor() {
+        return detectedVersionMajor;
+    }
+    public void setDetectedVersionMajor(int detectedVersionMajor) {
+        this.detectedVersionMajor = detectedVersionMajor;
+    }
+    public int getDetectedVersionMinor() {
+        return detectedVersionMinor;
+    }
+    public void setDetectedVersionMinor(int detectedVersionMinor) {
+        this.detectedVersionMinor = detectedVersionMinor;
+    }
+    @NonNull
+    @Override
+    public String toString() {
+        return getName();
+    }
+}
index 96f022b4ace6322765bb81acce5e83fa34e62a24..ac78e23128d5c6994e2f152e33402def4a639543 100644 (file)
@@ -40,7 +40,7 @@ import static net.ktnx.mobileledger.utils.Logger.debug;
 public class MobileLedgerDatabase extends SQLiteOpenHelper {
     public static final MutableLiveData<Boolean> initComplete = new MutableLiveData<>(false);
     public static final String DB_NAME = "MoLe.db";
-    private static final int LATEST_REVISION = 57;
+    private static final int LATEST_REVISION = 58;
     private static final String CREATE_DB_SQL = "create_db";
     private final Application mContext;
 
@@ -88,7 +88,7 @@ public class MobileLedgerDatabase extends SQLiteOpenHelper {
             InputStreamReader isr = new InputStreamReader(res);
             BufferedReader reader = new BufferedReader(isr);
 
-            Pattern endOfStatement = Pattern.compile(";\\s*(?:--.*)$");
+            Pattern endOfStatement = Pattern.compile(";\\s*(?:--.*)?$");
 
             String line;
             String sqlStatement = null;
@@ -121,8 +121,9 @@ public class MobileLedgerDatabase extends SQLiteOpenHelper {
             }
 
             if (sqlStatement != null)
-                throw new RuntimeException(
-                        String.format("Error applying %s: EOF after continuation", revFile));
+                throw new RuntimeException(String.format(
+                        "Error applying %s: EOF after continuation. Line %s, Incomplete " +
+                        "statement: %s", revFile, lineNo, sqlStatement));
 
         }
         catch (IOException e) {
index 39965ed3a3963033d83dc3c1fc59c4796fb82c45..a4a42eafc8fe418e37f7e4658375a8897a48cb54 100644 (file)
 
 BEGIN TRANSACTION;
 
-create table profiles(uuid varchar not null primary key, name not null, url not null, use_authentication boolean not null, auth_user varchar, auth_password varchar, order_no integer, permit_posting boolean default 0, theme integer default -1, preferred_accounts_filter varchar, future_dates integer, api_version integer, show_commodity_by_default boolean default 0, default_commodity varchar, show_comments_by_default boolean default 1, detected_version_pre_1_19 boolean, detected_version_major integer, detected_version_minor integer);
+create table profiles(
+ uuid text not null,
+ name text not null,
+ url text not null,
+ use_authentication integer not null,
+ auth_user text,
+ auth_password text,
+ order_no integer not null,
+ permit_posting integer not null default 0,
+ theme integer not null default -1,
+ preferred_accounts_filter varchar,
+ future_dates integer not null,
+ api_version integer not null,
+ show_commodity_by_default integer not null default 0,
+ default_commodity text,
+ show_comments_by_default integer not null default 1,
+ detected_version_pre_1_19 integer not null,
+ detected_version_major integer not null,
+ detected_version_minor integer not null,
+ primary key(uuid));
+
 create table accounts(profile varchar not null, name varchar not null, name_upper varchar not null, level integer not null, parent_name varchar, expanded integer not null default 1, amounts_expanded integer not null default 0, generation integer not null default 0, primary key(profile, name));
 create table options(profile varchar not null, name varchar not null, value varchar);
 create unique index un_options on options(profile,name);
@@ -37,4 +57,4 @@ create index fk_template_accounts_template on template_accounts(template_id);
 create index fk_template_accounts_currency on template_accounts(currency);
 
 COMMIT TRANSACTION;
--- updated to revision 56
\ No newline at end of file
+-- updated to revision 58
\ No newline at end of file
diff --git a/app/src/main/res/raw/sql_58.sql b/app/src/main/res/raw/sql_58.sql
new file mode 100644 (file)
index 0000000..4c99be2
--- /dev/null
@@ -0,0 +1,55 @@
+-- Copyright © 2021 Damyan Ivanov.
+-- This file is part of MoLe.
+-- MoLe is free software: you can distribute it and/or modify it
+-- under the term of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your opinion), any later version.
+--
+-- MoLe is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License terms for details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+
+-- profiles ground for  Room
+
+PRAGMA foreign_keys = OFF;
+BEGIN TRANSACTION;
+
+create table profiles(
+ uuid text not null,
+ name text not null,
+ url text not null,
+ use_authentication integer not null,
+ auth_user text,
+ auth_password text,
+ order_no integer not null,
+ permit_posting integer not null default 0,
+ theme integer not null default -1,
+ preferred_accounts_filter varchar,
+ future_dates integer not null,
+ api_version integer not null,
+ show_commodity_by_default integer not null default 0,
+ default_commodity text,
+ show_comments_by_default integer not null default 1,
+ detected_version_pre_1_19 integer not null,
+ detected_version_major integer not null,
+ detected_version_minor integer not null,
+ primary key(uuid));
+
+insert into profiles_new(
+ uuid, name, url, use_authentication, auth_user, auth_password, order_no,
+ permit_posting, theme, preferred_accounts_filter, future_dates, api_version,
+ show_commodity_by_default, default_commodity, show_comments_by_default,
+ detected_version_pre_1_19, detected_version_major, detected_version_minor)
+select uuid, name, url, use_authentication, auth_user, auth_password, order_no,
+ permit_posting, theme, preferred_accounts_filter, future_dates, api_version,
+ show_commodity_by_default, default_commodity, show_comments_by_default,
+ detected_version_pre_1_19, detected_version_major, detected_version_minor
+from profiles;
+
+COMMIT TRANSACTION;
+
+PRAGMA foreign_keys = ON;
\ No newline at end of file