]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/res/raw/sql_13.sql
let SQL revision files control the transaction
[mobile-ledger.git] / app / src / main / res / raw / sql_13.sql
1 -- Copyright © 2019 Damyan Ivanov.
2 -- This file is part of MoLe.
3 -- MoLe is free software: you can distribute it and/or modify it
4 -- under the term of the GNU General Public License as published by
5 -- the Free Software Foundation, either version 3 of the License, or
6 -- (at your opinion), any later version.
7 --
8 -- MoLe is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 -- GNU General Public License terms for details.
12 --
13 -- You should have received a copy of the GNU General Public License
14 -- along with MoLe. If not, see <https://www.gnu.org/licenses/>.
15
16 BEGIN TRANSACTION;
17
18 delete from options where name='transaction_list_last_update';
19 delete from options where name='last_refresh';
20 alter table options add profile varchar;
21 drop index idx_options_name;
22 create unique index un_options on options(profile,name);
23 --
24 drop table account_values;
25 create table account_values(profile varchar not null, account varchar not null, currency varchar not null default '', keep boolean, value decimal not null );
26 create unique index un_account_values on account_values(profile,account,currency);
27 --
28 drop table accounts;
29 create table accounts(profile varchar not null, name varchar not null, name_upper varchar not null, hidden boolean not null default 0, keep boolean not null default 0, level integer not null, parent_name varchar);
30 create unique index un_accounts on accounts(profile, name);
31 --
32 drop table transaction_accounts;
33 drop table transactions;
34 --
35 create table transactions(id integer not null, data_hash varchar not null, date varchar not null, description varchar not null, keep boolean not null default 0);
36 create unique index un_transactions_id on transactions(id);
37 create unique index un_transactions_data_hash on transactions(data_hash);
38 --
39 create table transaction_accounts(profile varchar not null, transaction_id integer not null, account_name varchar not null, currency varchar not null default '', amount decimal not null, constraint fk_transaction_accounts_acc foreign key(profile,account_name) references accounts(profile,account_name), constraint fk_transaction_accounts_trn foreign key(transaction_id) references transactions(id));
40
41 COMMIT TRANSACTION;