|
|
@ -5,7 +5,22 @@ create table SharedIds (
|
|
|
|
|
|
|
|
|
|
|
|
insert into SharedIds (name, next_id) values ('habitandgroup', (select coalesce(max(id),0) from Habits) + 1 );
|
|
|
|
insert into SharedIds (name, next_id) values ('habitandgroup', (select coalesce(max(id),0) from Habits) + 1 );
|
|
|
|
|
|
|
|
|
|
|
|
alter table Habits rename to HabitsOld;
|
|
|
|
create table HabitGroups (
|
|
|
|
|
|
|
|
id integer primary key,
|
|
|
|
|
|
|
|
archived integer,
|
|
|
|
|
|
|
|
color integer,
|
|
|
|
|
|
|
|
description text not null default "",
|
|
|
|
|
|
|
|
highlight integer,
|
|
|
|
|
|
|
|
name text,
|
|
|
|
|
|
|
|
position integer,
|
|
|
|
|
|
|
|
reminder_days integer not null default 127,
|
|
|
|
|
|
|
|
reminder_hour integer,
|
|
|
|
|
|
|
|
reminder_min integer,
|
|
|
|
|
|
|
|
question text not null default "",
|
|
|
|
|
|
|
|
uuid text
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alter table Habits rename to Habits_old;
|
|
|
|
|
|
|
|
|
|
|
|
create table Habits (
|
|
|
|
create table Habits (
|
|
|
|
id integer primary key,
|
|
|
|
id integer primary key,
|
|
|
@ -25,29 +40,37 @@ create table Habits (
|
|
|
|
target_value real not null default 0,
|
|
|
|
target_value real not null default 0,
|
|
|
|
unit text not null default "",
|
|
|
|
unit text not null default "",
|
|
|
|
question text,
|
|
|
|
question text,
|
|
|
|
uuid text
|
|
|
|
uuid text,
|
|
|
|
|
|
|
|
group_id integer,
|
|
|
|
|
|
|
|
group_uuid text,
|
|
|
|
|
|
|
|
foreign key(group_id)
|
|
|
|
|
|
|
|
references HabitGroups(id)
|
|
|
|
|
|
|
|
on update cascade
|
|
|
|
|
|
|
|
on delete cascade
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
insert into Habits (id, archived, color, description, freq_den, freq_num, highlight, name, position, reminder_min, reminder_days, type, target_type, target_value, unit, question, uuid)
|
|
|
|
insert into Habits (id, archived, color, description, freq_den, freq_num, highlight, name, position, reminder_min, reminder_days, type, target_type, target_value, unit, question, uuid)
|
|
|
|
select id, archived, color, description, freq_den, freq_num, highlight, name, position, reminder_min, reminder_days, type, target_type, target_value, unit, question, uuid
|
|
|
|
select id, archived, color, description, freq_den, freq_num, highlight, name, position, reminder_min, reminder_days, type, target_type, target_value, unit, question, uuid
|
|
|
|
from HabitsOld;
|
|
|
|
from Habits_old;
|
|
|
|
|
|
|
|
|
|
|
|
drop table HabitsOld;
|
|
|
|
PRAGMA foreign_keys = OFF;
|
|
|
|
|
|
|
|
begin transaction;
|
|
|
|
|
|
|
|
|
|
|
|
create table HabitGroups (
|
|
|
|
alter table Repetitions rename to Repetitions_old;
|
|
|
|
id integer primary key,
|
|
|
|
create table Repetitions (
|
|
|
|
archived integer,
|
|
|
|
id integer primary key autoincrement,
|
|
|
|
color integer,
|
|
|
|
habit integer,
|
|
|
|
description text not null default "",
|
|
|
|
timestamp integer,
|
|
|
|
highlight integer,
|
|
|
|
value integer not null,
|
|
|
|
name text,
|
|
|
|
notes text,
|
|
|
|
position integer,
|
|
|
|
foreign key (habit)
|
|
|
|
reminder_days integer not null default 127,
|
|
|
|
references Habits(id)
|
|
|
|
reminder_hour integer,
|
|
|
|
on update cascade
|
|
|
|
reminder_min integer,
|
|
|
|
on delete cascade
|
|
|
|
question text not null default "",
|
|
|
|
|
|
|
|
uuid text
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into Repetitions select * from Repetitions_old;
|
|
|
|
|
|
|
|
drop table Repetitions_old;
|
|
|
|
|
|
|
|
drop table Habits_old;
|
|
|
|
|
|
|
|
|
|
|
|
alter table Habits add column group_uuid text references habitgroups(uuid);
|
|
|
|
commit;
|
|
|
|
alter table Habits add column group_id integer references habitgroups(id);
|
|
|
|
PRAGMA foreign_keys = ON;
|