]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/res/raw/sql_58.sql
describe description_history to Room
[mobile-ledger.git] / app / src / main / res / raw / sql_58.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 -- profiles ground for  Room
17
18 PRAGMA foreign_keys = OFF;
19 BEGIN TRANSACTION;
20
21 create table profiles(
22  uuid text not null,
23  name text not null,
24  url text not null,
25  use_authentication integer not null,
26  auth_user text,
27  auth_password text,
28  order_no integer not null,
29  permit_posting integer not null default 0,
30  theme integer not null default -1,
31  preferred_accounts_filter varchar,
32  future_dates integer not null,
33  api_version integer not null,
34  show_commodity_by_default integer not null default 0,
35  default_commodity text,
36  show_comments_by_default integer not null default 1,
37  detected_version_pre_1_19 integer not null,
38  detected_version_major integer not null,
39  detected_version_minor integer not null,
40  primary key(uuid));
41
42 insert into profiles_new(
43  uuid, name, url, use_authentication, auth_user, auth_password, order_no,
44  permit_posting, theme, preferred_accounts_filter, future_dates, api_version,
45  show_commodity_by_default, default_commodity, show_comments_by_default,
46  detected_version_pre_1_19, detected_version_major, detected_version_minor)
47 select uuid, name, url, use_authentication, auth_user, auth_password, order_no,
48  permit_posting, theme, preferred_accounts_filter, future_dates, api_version,
49  show_commodity_by_default, default_commodity, show_comments_by_default,
50  detected_version_pre_1_19, detected_version_major, detected_version_minor
51 from profiles;
52
53 drop table profiles;
54
55 alter table profiles_new
56 rename to profiles;
57
58 create table options_new(profile varchar not null, name varchar not null, value varchar, primary key(profile, name));
59
60 insert into options_new(profile, name, value)
61 select profile, name, value from options;
62
63 drop table options;
64
65 alter table options_new
66 rename to options;
67
68 create table account_values_new(
69  profile varchar not null,
70  account varchar not null,
71  currency varchar not null default '',
72  value real not null,
73  generation integer not null default 0,
74  primary key(profile, account, currency));
75
76 insert into account_values_new(
77  profile, account, currency, value, generation)
78 select profile, account, currency, value, generation
79 from account_values;
80
81 drop table account_values;
82 alter table account_values_new rename to account_values;
83
84 create table description_history_new(
85  description varchar collate NOCASE not null primary key,
86  description_upper varchar not null,
87  generation integer not null default 0,
88  primary key(description));
89
90 insert into description_history_new(description, description_upper, generation)
91 select description, description_upper, generation from description_history;
92
93 drop table description_history;
94 alter table description_history_new rename to description_history;
95
96 COMMIT TRANSACTION;
97
98 PRAGMA foreign_keys = ON;