mirror of https://github.com/iSoron/uhabits.git
parent
0a5d565030
commit
71fe6137be
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package org.isoron.androidbase.storage;
|
||||
|
||||
public class UnsupportedDatabaseVersionException extends RuntimeException
|
||||
{
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
delete from Score;
|
||||
delete from Streak;
|
||||
delete from Checkmarks;
|
||||
delete from Checkmarks;
|
@ -1 +1 @@
|
||||
alter table habits add column reminder_days integer not null default 127;
|
||||
alter table Habits add column reminder_days integer not null default 127;
|
@ -1,4 +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);
|
||||
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);
|
@ -1,5 +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;
|
||||
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;
|
@ -0,0 +1,6 @@
|
||||
create table Events (
|
||||
id integer primary key autoincrement,
|
||||
timestamp integer,
|
||||
message text,
|
||||
server_id integer
|
||||
);
|
@ -1,2 +0,0 @@
|
||||
alter table habits add column reminder_hour integer;
|
||||
alter table habits add column reminder_min integer;
|
@ -1 +0,0 @@
|
||||
alter table habits add column highlight integer not null default 0;
|
@ -1 +0,0 @@
|
||||
alter table habits add column archived integer not null default 0;
|
@ -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
|
||||
);
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits;
|
||||
|
||||
import android.content.*;
|
||||
import android.database.sqlite.*;
|
||||
|
||||
import org.isoron.androidbase.storage.*;
|
||||
|
||||
|
||||
public class HabitsDatabaseOpener extends BaseSQLiteOpenHelper
|
||||
{
|
||||
private final int version;
|
||||
|
||||
public HabitsDatabaseOpener(Context context,
|
||||
String databaseFilename,
|
||||
int version)
|
||||
{
|
||||
super(context, databaseFilename, version);
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db)
|
||||
{
|
||||
onUpgrade(db, 8, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
|
||||
{
|
||||
if(oldVersion < 8) throw new UnsupportedDatabaseVersionException();
|
||||
super.onUpgrade(db, oldVersion, newVersion);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue