]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/res/raw/sql_54.sql
add missing/fix copyright statements to all SQL revision files
[mobile-ledger.git] / app / src / main / res / raw / sql_54.sql
1 -- Copyright © 2021 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 -- copied from the Room migration
17
18 CREATE TABLE templates (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT NOT NULL, regular_expression TEXT NOT NULL, test_text TEXT, transaction_description TEXT, transaction_description_match_group INTEGER, transaction_comment TEXT, transaction_comment_match_group INTEGER, date_year INTEGER, date_year_match_group INTEGER, date_month INTEGER, date_month_match_group INTEGER, date_day INTEGER, date_day_match_group INTEGER);
19 CREATE TABLE template_accounts (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, template_id INTEGER NOT NULL, acc TEXT, position INTEGER NOT NULL, acc_match_group INTEGER, currency INTEGER, currency_match_group INTEGER, amount REAL, amount_match_group INTEGER, comment TEXT, comment_match_group INTEGER, negate_amount INTEGER, FOREIGN KEY(template_id) REFERENCES templates(id) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(currency) REFERENCES currencies(id) ON UPDATE NO ACTION ON DELETE NO ACTION);
20 insert into templates(id, name, regular_expression, test_text, transaction_description, transaction_description_match_group, transaction_comment, transaction_comment_match_group, date_year, date_year_match_group, date_month, date_month_match_group, date_day, date_day_match_group) select id, name, regular_expression, test_text, transaction_description, transaction_description_match_group, transaction_comment, transaction_comment_match_group, date_year, date_year_match_group, date_month, date_month_match_group, date_day, date_day_match_group from patterns;
21 insert into template_accounts(id, template_id, acc, position, acc_match_group, currency, currency_match_group, amount, amount_match_group, amount, amount_match_group, comment, comment_match_group, negate_amount) select id, pattern_id, acc, position, acc_match_group, currency, currency_match_group, amount, amount_match_group, amount, amount_match_group, comment, comment_match_group, negate_amount from pattern_accounts;
22 create index fk_template_accounts_template on template_accounts(template_id);
23 create index fk_template_accounts_currency on template_accounts(currency);
24 drop table pattern_accounts;
25 drop table patterns;