mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Move uhabits-core to top level; all Java files to uhabits-core:jvmMain/jvmTest
This commit is contained in:
41
uhabits-core/src/jvmMain/resources/migrations/09.sql
Normal file
41
uhabits-core/src/jvmMain/resources/migrations/09.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
create table Habits (
|
||||
id integer primary key autoincrement,
|
||||
archived integer,
|
||||
color integer,
|
||||
description text,
|
||||
freq_den integer,
|
||||
freq_num integer,
|
||||
highlight integer,
|
||||
name text,
|
||||
position integer,
|
||||
reminder_hour integer,
|
||||
reminder_min integer
|
||||
);
|
||||
|
||||
create table Checkmarks (
|
||||
id integer primary key autoincrement,
|
||||
habit integer references habits(id),
|
||||
timestamp integer,
|
||||
value integer
|
||||
);
|
||||
|
||||
create table Repetitions (
|
||||
id integer primary key autoincrement,
|
||||
habit integer references habits(id),
|
||||
timestamp integer
|
||||
);
|
||||
|
||||
create table Streak (
|
||||
id integer primary key autoincrement,
|
||||
end integer,
|
||||
habit integer references habits(id),
|
||||
length integer,
|
||||
start integer
|
||||
);
|
||||
|
||||
create table Score (
|
||||
id integer primary key autoincrement,
|
||||
habit integer references habits(id),
|
||||
score integer,
|
||||
timestamp integer
|
||||
);
|
||||
3
uhabits-core/src/jvmMain/resources/migrations/10.sql
Normal file
3
uhabits-core/src/jvmMain/resources/migrations/10.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
delete from Score;
|
||||
delete from Streak;
|
||||
delete from Checkmarks;
|
||||
1
uhabits-core/src/jvmMain/resources/migrations/11.sql
Normal file
1
uhabits-core/src/jvmMain/resources/migrations/11.sql
Normal file
@@ -0,0 +1 @@
|
||||
alter table Habits add column reminder_days integer not null default 127;
|
||||
3
uhabits-core/src/jvmMain/resources/migrations/12.sql
Normal file
3
uhabits-core/src/jvmMain/resources/migrations/12.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
delete from Score;
|
||||
delete from Streak;
|
||||
delete from Checkmarks;
|
||||
4
uhabits-core/src/jvmMain/resources/migrations/13.sql
Normal file
4
uhabits-core/src/jvmMain/resources/migrations/13.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
create index idx_score_habit_timestamp on Score(habit, timestamp);
|
||||
create index idx_checkmark_habit_timestamp on Checkmarks(habit, timestamp);
|
||||
create index idx_repetitions_habit_timestamp on Repetitions(habit, timestamp);
|
||||
create index idx_streak_habit_end on Streak(habit, end);
|
||||
14
uhabits-core/src/jvmMain/resources/migrations/14.sql
Normal file
14
uhabits-core/src/jvmMain/resources/migrations/14.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
update habits set color=0 where color=-2937041;
|
||||
update habits set color=1 where color=-1684967;
|
||||
update habits set color=2 where color=-415707;
|
||||
update habits set color=3 where color=-5262293;
|
||||
update habits set color=4 where color=-13070788;
|
||||
update habits set color=5 where color=-16742021;
|
||||
update habits set color=6 where color=-16732991;
|
||||
update habits set color=7 where color=-16540699;
|
||||
update habits set color=8 where color=-10603087;
|
||||
update habits set color=9 where color=-7461718;
|
||||
update habits set color=10 where color=-2614432;
|
||||
update habits set color=11 where color=-13619152;
|
||||
update habits set color=12 where color=-5592406;
|
||||
update habits set color=0 where color<0 or color>12;
|
||||
3
uhabits-core/src/jvmMain/resources/migrations/15.sql
Normal file
3
uhabits-core/src/jvmMain/resources/migrations/15.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
delete from Score;
|
||||
delete from Streak;
|
||||
delete from Checkmarks;
|
||||
2
uhabits-core/src/jvmMain/resources/migrations/16.sql
Normal file
2
uhabits-core/src/jvmMain/resources/migrations/16.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
alter table Habits add column type integer not null default 0;
|
||||
alter table Repetitions add column value integer not null default 2;
|
||||
11
uhabits-core/src/jvmMain/resources/migrations/17.sql
Normal file
11
uhabits-core/src/jvmMain/resources/migrations/17.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
drop table Score;
|
||||
create table Score (
|
||||
id integer primary key autoincrement,
|
||||
habit integer references habits(id),
|
||||
score real,
|
||||
timestamp integer);
|
||||
|
||||
create index idx_score_habit_timestamp on Score(habit, timestamp);
|
||||
|
||||
delete from streak;
|
||||
delete from checkmarks;
|
||||
3
uhabits-core/src/jvmMain/resources/migrations/18.sql
Normal file
3
uhabits-core/src/jvmMain/resources/migrations/18.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
alter table Habits add column target_type integer not null default 0;
|
||||
alter table Habits add column target_value real not null default 0;
|
||||
alter table Habits add column unit text not null default "";
|
||||
6
uhabits-core/src/jvmMain/resources/migrations/19.sql
Normal file
6
uhabits-core/src/jvmMain/resources/migrations/19.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
create table Events (
|
||||
id integer primary key autoincrement,
|
||||
timestamp integer,
|
||||
message text,
|
||||
server_id integer
|
||||
);
|
||||
3
uhabits-core/src/jvmMain/resources/migrations/20.sql
Normal file
3
uhabits-core/src/jvmMain/resources/migrations/20.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
drop table checkmarks;
|
||||
drop table streak;
|
||||
drop table score;
|
||||
12
uhabits-core/src/jvmMain/resources/migrations/21.sql
Normal file
12
uhabits-core/src/jvmMain/resources/migrations/21.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
update habits set color=19 where color=12;
|
||||
update habits set color=17 where color=11;
|
||||
update habits set color=15 where color=10;
|
||||
update habits set color=14 where color=9;
|
||||
update habits set color=13 where color=8;
|
||||
update habits set color=10 where color=7;
|
||||
update habits set color=9 where color=6;
|
||||
update habits set color=8 where color=5;
|
||||
update habits set color=7 where color=4;
|
||||
update habits set color=5 where color=3;
|
||||
update habits set color=4 where color=2;
|
||||
update habits set color=0 where color<0 or color>19;
|
||||
24
uhabits-core/src/jvmMain/resources/migrations/22.sql
Normal file
24
uhabits-core/src/jvmMain/resources/migrations/22.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
delete from repetitions where habit not in (select id from habits);
|
||||
delete from repetitions where timestamp is null;
|
||||
delete from repetitions where habit is null;
|
||||
delete from repetitions where rowid not in (
|
||||
select min(rowid) from repetitions group by habit, timestamp
|
||||
);
|
||||
|
||||
begin transaction;
|
||||
|
||||
alter table Repetitions rename to RepetitionsBak;
|
||||
create table Repetitions (
|
||||
id integer primary key autoincrement,
|
||||
habit integer not null references habits(id),
|
||||
timestamp integer not null,
|
||||
value integer not null);
|
||||
drop index if exists idx_repetitions_habit_timestamp;
|
||||
create unique index idx_repetitions_habit_timestamp on Repetitions(
|
||||
habit, timestamp);
|
||||
insert into Repetitions select * from RepetitionsBak;
|
||||
drop table RepetitionsBak;
|
||||
|
||||
commit;
|
||||
|
||||
pragma foreign_keys=ON;
|
||||
5
uhabits-core/src/jvmMain/resources/migrations/23.sql
Normal file
5
uhabits-core/src/jvmMain/resources/migrations/23.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
alter table Habits add column question text;
|
||||
|
||||
update Habits set question = description;
|
||||
|
||||
update Habits set description = "";
|
||||
2
uhabits-core/src/jvmMain/resources/migrations/24.sql
Normal file
2
uhabits-core/src/jvmMain/resources/migrations/24.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
alter table habits add column uuid text;
|
||||
update habits set uuid = lower(hex(randomblob(16) || id));
|
||||
Reference in New Issue
Block a user