"formatVersion": 1,
"database": {
"version": 58,
- "identityHash": "44f57b04fd657bffc7f36554b678696f",
+ "identityHash": "ce42602c9c1d3edae4cb67fa54bc6f76",
"entities": [
{
"tableName": "templates",
},
"indices": [],
"foreignKeys": []
+ },
+ {
+ "tableName": "account_values",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profile` TEXT NOT NULL, `account` TEXT NOT NULL, `currency` TEXT NOT NULL DEFAULT '', `value` REAL NOT NULL, `generation` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`profile`, `account`, `currency`))",
+ "fields": [
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "account",
+ "columnName": "account",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "currency",
+ "columnName": "currency",
+ "affinity": "TEXT",
+ "notNull": true,
+ "defaultValue": "''"
+ },
+ {
+ "fieldPath": "value",
+ "columnName": "value",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "generation",
+ "columnName": "generation",
+ "affinity": "INTEGER",
+ "notNull": true,
+ "defaultValue": "0"
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "profile",
+ "account",
+ "currency"
+ ],
+ "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, '44f57b04fd657bffc7f36554b678696f')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ce42602c9c1d3edae4cb67fa54bc6f76')"
]
}
}
\ No newline at end of file
--- /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;
+
+/*
+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);
+ */
+@Entity(tableName = "account_values", primaryKeys = {"profile", "account", "currency"})
+public class AccountValue {
+ @ColumnInfo
+ @NonNull
+ private String profile;
+ @ColumnInfo
+ @NonNull
+ private String account;
+ @NonNull
+ @ColumnInfo(defaultValue = "")
+ private String currency = "";
+ @ColumnInfo
+ private float value;
+ @ColumnInfo(defaultValue = "0")
+ private int generation = 0;
+ @NonNull
+ public String getProfile() {
+ return profile;
+ }
+ public void setProfile(@NonNull String profile) {
+ this.profile = profile;
+ }
+ @NonNull
+ public String getAccount() {
+ return account;
+ }
+ public void setAccount(@NonNull String account) {
+ this.account = account;
+ }
+ @NonNull
+ public String getCurrency() {
+ return currency;
+ }
+ public void setCurrency(@NonNull String currency) {
+ this.currency = currency;
+ }
+ public float getValue() {
+ return value;
+ }
+ public void setValue(float value) {
+ this.value = value;
+ }
+ public int getGeneration() {
+ return generation;
+ }
+ public void setGeneration(int generation) {
+ this.generation = generation;
+ }
+}
@Database(version = 58,
entities = {TemplateHeader.class, TemplateAccount.class, Currency.class, Account.class,
- Profile.class, Option.class
+ Profile.class, Option.class, AccountValue.class
})
abstract public class DB extends RoomDatabase {
private static DB instance;
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, 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 account_values(
+ profile varchar not null,
+ account varchar not null,
+ currency varchar not null default '',
+ value real not null,
+ generation integer not null default 0,
+ primary key(profile, account, currency));
+
create table description_history(description varchar not null primary key, description_upper varchar, generation integer default 0);
create unique index un_description_history on description_history(description_upper);
create table transactions(profile varchar not null, id integer not null, data_hash varchar not null, year integer not null, month integer not null, day integer not null, description varchar not null, comment varchar, generation integer default 0);
alter table options_new
rename to options;
+create table account_values_new(
+ profile varchar not null,
+ account varchar not null,
+ currency varchar not null default '',
+ value real not null,
+ generation integer not null default 0,
+ primary key(profile, account, currency));
+
+insert into account_values_new(
+ profile, account, currency, value, generation)
+select profile, account, currency, value, generation
+from account_values;
+
+drop table account_values;
+alter table account_values_new rename to account_values;
+
+
COMMIT TRANSACTION;
PRAGMA foreign_keys = ON;
\ No newline at end of file