X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fres%2Fraw%2Fsql_58.sql;h=ad28d1a5ba010b6fd2fe005084b1088ed0c6fb55;hb=d5218337e111a377a3661f0ae4a5049edc055705;hp=ab3d08865146330ed513aab66d2e9c2c837e05ff;hpb=b2f4ea6b9b96cda1c04afc54c152049025d99d80;p=mobile-ledger.git diff --git a/app/src/main/res/raw/sql_58.sql b/app/src/main/res/raw/sql_58.sql index ab3d0886..ad28d1a5 100644 --- a/app/src/main/res/raw/sql_58.sql +++ b/app/src/main/res/raw/sql_58.sql @@ -93,6 +93,58 @@ 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); + +-- transaction_accounts + +create table transaction_accounts_new( + profile varchar not null, + transaction_id integer not null, + order_no integer not null, + account_name varchar not null, + currency varchar not null default '', + amount real not null, + comment varchar, + generation integer not null default 0, + primary key(profile, transaction_id, order_no), + foreign key (profile,account_name) references accounts(profile,name) + on delete cascade on update restrict, + foreign key(profile, transaction_id) references transactions(profile,id) + on delete cascade on update restrict); + +insert into transaction_accounts_new(profile, transaction_id, order_no, account_name, + currency, amount, comment, generation) +select profile, transaction_id, order_no, account_name, + currency, amount, comment, generation +from transaction_accounts; + +drop table transaction_accounts; +alter table transaction_accounts_new rename to transaction_accounts; + COMMIT TRANSACTION; PRAGMA foreign_keys = ON; \ No newline at end of file