"formatVersion": 1,
"database": {
"version": 58,
- "identityHash": "ba63bc73720c33314f20ec5312984ab4",
+ "identityHash": "44f57b04fd657bffc7f36554b678696f",
"entities": [
{
"tableName": "templates",
},
"indices": [],
"foreignKeys": []
+ },
+ {
+ "tableName": "options",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profile` TEXT NOT NULL, `name` TEXT NOT NULL, `value` TEXT, PRIMARY KEY(`profile`, `name`))",
+ "fields": [
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "value",
+ "columnName": "value",
+ "affinity": "TEXT",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "profile",
+ "name"
+ ],
+ "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')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '44f57b04fd657bffc7f36554b678696f')"
]
}
}
\ No newline at end of file
@Database(version = 58,
entities = {TemplateHeader.class, TemplateAccount.class, Currency.class, Account.class,
- Profile.class
+ Profile.class, Option.class
})
abstract public class DB extends RoomDatabase {
private static DB instance;
--- /dev/null
+/*
+ * 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;
+
+@Entity(tableName = "options", primaryKeys = {"profile", "name"})
+public class Option {
+ @NonNull
+ @ColumnInfo
+ private String profile = "invalid";
+ @NonNull
+ @ColumnInfo
+ private String name = "";
+ @ColumnInfo
+ private String value;
+ @NonNull
+ public String getProfile() {
+ return profile;
+ }
+ public void setProfile(@NonNull String profile) {
+ this.profile = profile;
+ }
+ @NonNull
+ public String getName() {
+ return name;
+ }
+ public void setName(@NonNull String name) {
+ this.name = name;
+ }
+ public String getValue() {
+ return value;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
+ @NonNull
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
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);
+create table options(profile varchar not null, name varchar not null, value varchar, primary key(profile, name));
+
create table account_values(profile varchar not null, account varchar not null, currency varchar not null default '', value decimal not null, generation integer default 0 );
create unique index un_account_values on account_values(profile,account,currency);
create table description_history(description varchar not null primary key, description_upper varchar, generation integer default 0);
detected_version_pre_1_19, detected_version_major, detected_version_minor
from profiles;
+drop table profiles;
+
+alter table profiles_new
+rename to profiles;
+
+create table options_new(profile varchar not null, name varchar not null, value varchar, primary key(profile, name));
+
+insert into options_new(profile, name, value)
+select profile, name, value from options;
+
+drop table options;
+
+alter table options_new
+rename to options;
+
COMMIT TRANSACTION;
PRAGMA foreign_keys = ON;
\ No newline at end of file