"formatVersion": 1,
"database": {
"version": 58,
- "identityHash": "ce42602c9c1d3edae4cb67fa54bc6f76",
+ "identityHash": "00d9b541473347c65a90e47ce9072436",
"entities": [
{
"tableName": "templates",
},
"indices": [],
"foreignKeys": []
+ },
+ {
+ "tableName": "description_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`description` TEXT NOT NULL COLLATE NOCASE, `description_upper` TEXT NOT NULL, `generation` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`description`))",
+ "fields": [
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "descriptionUpper",
+ "columnName": "description_upper",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "generation",
+ "columnName": "generation",
+ "affinity": "INTEGER",
+ "notNull": true,
+ "defaultValue": "0"
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "description"
+ ],
+ "autoGenerate": false
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "transactions",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profile` TEXT NOT NULL, `id` INTEGER NOT NULL, `data_hash` TEXT NOT NULL, `year` INTEGER NOT NULL, `month` INTEGER NOT NULL, `day` INTEGER NOT NULL, `description` TEXT NOT NULL COLLATE NOCASE, `comment` TEXT, `generation` INTEGER NOT NULL, PRIMARY KEY(`profile`, `id`))",
+ "fields": [
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dataHash",
+ "columnName": "data_hash",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "month",
+ "columnName": "month",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "day",
+ "columnName": "day",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "comment",
+ "columnName": "comment",
+ "affinity": "TEXT",
+ "notNull": false
+ },
+ {
+ "fieldPath": "generation",
+ "columnName": "generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "profile",
+ "id"
+ ],
+ "autoGenerate": false
+ },
+ "indices": [
+ {
+ "name": "un_transactions_data_hash",
+ "unique": true,
+ "columnNames": [
+ "profile",
+ "data_hash"
+ ],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `un_transactions_data_hash` ON `${TABLE_NAME}` (`profile`, `data_hash`)"
+ },
+ {
+ "name": "idx_transaction_description",
+ "unique": false,
+ "columnNames": [
+ "description"
+ ],
+ "createSql": "CREATE INDEX IF NOT EXISTS `idx_transaction_description` ON `${TABLE_NAME}` (`description`)"
+ }
+ ],
+ "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, 'ce42602c9c1d3edae4cb67fa54bc6f76')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '00d9b541473347c65a90e47ce9072436')"
]
}
}
\ No newline at end of file
@Database(version = 58,
entities = {TemplateHeader.class, TemplateAccount.class, Currency.class, Account.class,
- Profile.class, Option.class, AccountValue.class
+ Profile.class, Option.class, AccountValue.class, DescriptionHistory.class,
+ Transaction.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 = "description_history", primaryKeys = {"description"})
+public class DescriptionHistory {
+ @ColumnInfo(collate = ColumnInfo.NOCASE)
+ @NonNull
+ private String description;
+ @ColumnInfo(name = "description_upper")
+ @NonNull
+ private String descriptionUpper;
+ @ColumnInfo(defaultValue = "0")
+ private int generation = 0;
+ @NonNull
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(@NonNull String description) {
+ this.description = description;
+ }
+ @NonNull
+ public String getDescriptionUpper() {
+ return descriptionUpper;
+ }
+ public void setDescriptionUpper(@NonNull String descriptionUpper) {
+ this.descriptionUpper = descriptionUpper;
+ }
+ public int getGeneration() {
+ return generation;
+ }
+ public void setGeneration(int generation) {
+ this.generation = generation;
+ }
+}
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 description_history(description varchar collate NOCASE not null,
+ description_upper varchar not null,
+ generation integer not null default 0,
+ primary key(description));
+
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);
create unique index un_transactions_id on transactions(profile,id);
create unique index un_transactions_data_hash on transactions(profile,data_hash);
drop table account_values;
alter table account_values_new rename to account_values;
+create table description_history_new(
+ description varchar collate NOCASE not null primary key,
+ description_upper varchar not null,
+ generation integer not null default 0,
+ primary key(description));
+
+insert into description_history_new(description, description_upper, generation)
+select description, description_upper, generation from description_history;
+
+drop table description_history;
+alter table description_history_new rename to description_history;
COMMIT TRANSACTION;