]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/res/raw/sql_58.sql
describe transactions to Room
[mobile-ledger.git] / app / src / main / res / raw / sql_58.sql
index 066f22835bb3165f27e9756b5903568a28c49ac8..b2b687c587e1158c0f3c4bfa575d724b87bd5085 100644 (file)
@@ -65,6 +65,61 @@ drop table options;
 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;
+
+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;
+
+-- transactions
+
+create table transactions_new(
+ 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 collate NOCASE not null,
+ comment varchar,
+ generation integer not null default 0,
+ primary key(profile,id));
+
+insert into transactions_new(profile, id, data_hash, year, month, day, description,
+ comment, generation)
+select profile, id, data_hash, year, month, day, description,
+       comment, generation
+from transactions;
+
+drop table transactions;
+alter table transactions_new rename to transactions;
+
+create unique index un_transactions_data_hash on transactions(profile,data_hash);
+create index idx_transaction_description on transactions(description);
+
+
 COMMIT TRANSACTION;
 
 PRAGMA foreign_keys = ON;
\ No newline at end of file