Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 929375fb authored by Marten Gajda's avatar Marten Gajda Committed by GitHub
Browse files

Add INSTANCE_ORIGINAL_TIME column to instances. Implements #564 (#565)

This adds a column to the instances table to hold the original date and time of an instance. To make this easier instance creation has been refactored into smaller components.
This is a prerequisite for recurrence support.
parent f9bb3fd9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@ TARGET_SDK_VERSION=25
SUPPORT_LIBRARY_VERSION=25.4.0
CONTENTPAL_VERSION=3effe48
ROBOLECTRIC_VERSION=3.1.4
JEMS_VERSION=1.13
JEMS_VERSION=1.15
LIB_RECUR_VERSION=0.10.1
ANDROID_TEST_RUNNER_VERSION=0.5
RFC5545_DATETIME_VERSION=0.2.4
BOLTS_VERSION=92914c5
+8 −0
Original line number Diff line number Diff line
@@ -1035,6 +1035,14 @@ public final class TaskContract
         */
        String INSTANCE_DURATION = "instance_duration";

        /**
         * The start of the original instance as specified in the master task. For non-recurring task instances this equals the value of {@link
         * #INSTANCE_START}, except that `null` values are represented as `0`.
         * <p>
         * For recurring tasks, these are the timestamps which have been derived from the recurrence rule or dates, except those specified as exdates.
         */
        String INSTANCE_ORIGINAL_TIME = "instance_original_time";

    }


+4 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ dependencies {
    api project(':opentasks-contract')

    implementation 'org.dmfs:rfc5545-datetime:' + RFC5545_DATETIME_VERSION
    implementation 'org.dmfs:lib-recur:0.9.6'
    implementation 'org.dmfs:lib-recur:' + LIB_RECUR_VERSION
    implementation 'org.dmfs:jems:' + JEMS_VERSION

    androidTestImplementation project(':opentaskspal')
@@ -41,5 +41,7 @@ dependencies {
    androidTestImplementation 'com.android.support:support-annotations:' + SUPPORT_LIBRARY_VERSION
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test:rules:0.5'
    androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
    testImplementation 'org.robolectric:robolectric:' + ROBOLECTRIC_VERSION
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.hamcrest:hamcrest-all:1.3'
}
+185 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import org.dmfs.android.contentpal.operations.Put;
import org.dmfs.android.contentpal.operations.Referring;
import org.dmfs.android.contentpal.predicates.AllOf;
import org.dmfs.android.contentpal.predicates.EqArg;
import org.dmfs.android.contentpal.predicates.IsNull;
import org.dmfs.android.contentpal.queues.BasicOperationsQueue;
import org.dmfs.android.contentpal.rowdata.Composite;
import org.dmfs.android.contentpal.rowdata.EmptyRowData;
@@ -63,6 +64,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.TimeZone;

import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
import static org.junit.Assert.assertThat;

@@ -141,7 +144,15 @@ public class TaskProviderTest
        ), resultsIn(mClient,
                new Assert<>(taskList, new NameData("list1")),
                new Assert<>(task, new TitleData("task1")),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task)
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task, new AllOf(
                        new IsNull(Instances.INSTANCE_START),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, 0),
                        new IsNull(Instances.INSTANCE_DUE),
                        new IsNull(Instances.INSTANCE_START_SORTING),
                        new IsNull(Instances.INSTANCE_DUE_SORTING),
                        new IsNull(Instances.INSTANCE_DURATION),
                        new IsNull(Tasks.TZ)
                ))
        ));
    }

@@ -172,9 +183,33 @@ public class TaskProviderTest
                new Assert<>(task1, new TitleData("task1")),
                new Assert<>(task2, new TitleData("task2")),
                new Assert<>(task3, new TitleData("task3")),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task1),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task2),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task3)
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task1, new AllOf(
                        new IsNull(Instances.INSTANCE_START),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, 0),
                        new IsNull(Instances.INSTANCE_DUE),
                        new IsNull(Instances.INSTANCE_START_SORTING),
                        new IsNull(Instances.INSTANCE_DUE_SORTING),
                        new IsNull(Instances.INSTANCE_DURATION),
                        new IsNull(Tasks.TZ)
                )),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task2, new AllOf(
                        new IsNull(Instances.INSTANCE_START),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, 0),
                        new IsNull(Instances.INSTANCE_DUE),
                        new IsNull(Instances.INSTANCE_START_SORTING),
                        new IsNull(Instances.INSTANCE_DUE_SORTING),
                        new IsNull(Instances.INSTANCE_DURATION),
                        new IsNull(Tasks.TZ)
                )),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task3, new AllOf(
                        new IsNull(Instances.INSTANCE_START),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, 0),
                        new IsNull(Instances.INSTANCE_DUE),
                        new IsNull(Instances.INSTANCE_START_SORTING),
                        new IsNull(Instances.INSTANCE_DUE_SORTING),
                        new IsNull(Instances.INSTANCE_DURATION),
                        new IsNull(Tasks.TZ)
                ))
        ));
    }

@@ -199,7 +234,111 @@ public class TaskProviderTest
                new Assert<>(task, new TimeData(start, due)),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task, new AllOf(
                        new EqArg(Instances.INSTANCE_START, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, due.getTimestamp()),
                        new EqArg(Instances.INSTANCE_START_SORTING, start.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, due.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DURATION, due.getTimestamp() - start.getTimestamp()),
                        new EqArg(Tasks.TZ, start.isAllDay() ? "UTC" : start.getTimeZone().getID())
                ))
        ));
    }


    /**
     * Create task with start and due and update it with new values, check datetime values including generated duration.
     */
    @Test
    public void testInsertTaskWithStartAndDueMovedForward()
    {
        RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
        RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));

        DateTime start = DateTime.now();
        DateTime due = start.addDuration(new Duration(1, 1, 0));
        Duration duration = new Duration(1, 2, 0);

        DateTime startNew = start.addDuration(duration);
        DateTime dueNew = due.addDuration(duration);

        assertThat(new Seq<>(
                new Put<>(taskList, new EmptyRowData<TaskLists>()),
                new Put<>(task, new TimeData(start, due)),
                new Put<>(task, new TimeData(startNew, dueNew))
        ), resultsIn(mClient,
                new Assert<>(task, new TimeData(startNew, dueNew)),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task, new AllOf(
                        new EqArg(Instances.INSTANCE_START, startNew.getTimestamp()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, startNew.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, dueNew.getTimestamp()),
                        new EqArg(Instances.INSTANCE_START_SORTING, startNew.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, dueNew.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DURATION, dueNew.getTimestamp() - startNew.getTimestamp()),
                        new EqArg(Tasks.TZ, start.isAllDay() ? "UTC" : start.getTimeZone().getID())
                ))
        ));
    }


    /**
     * Create task with start and due and update it with new values, check datetime values including generated duration.
     */
    @Test
    public void testInsertTaskWithStartAndDueMovedBackwards()
    {
        RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
        RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));

        DateTime start = DateTime.now();
        DateTime due = start.addDuration(new Duration(1, 1, 0));
        Duration duration = new Duration(-1, 2, 0);

        DateTime startNew = start.addDuration(duration);
        DateTime dueNew = due.addDuration(duration);

        assertThat(new Seq<>(
                new Put<>(taskList, new EmptyRowData<TaskLists>()),
                new Put<>(task, new TimeData(start, due)),
                new Put<>(task, new TimeData(startNew, dueNew))
        ), resultsIn(mClient,
                new Assert<>(task, new TimeData(startNew, dueNew)),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task, new AllOf(
                        new EqArg(Instances.INSTANCE_START, startNew.getTimestamp()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, startNew.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, dueNew.getTimestamp()),
                        new EqArg(Instances.INSTANCE_START_SORTING, startNew.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, dueNew.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DURATION, dueNew.getTimestamp() - startNew.getTimestamp()),
                        new EqArg(Tasks.TZ, start.isAllDay() ? "UTC" : start.getTimeZone().getID())
                ))
        ));
    }


    /**
     * Create task without dates and set start and due afterwards, check datetime values including generated duration.
     */
    @Test
    public void testInsertTaskWithStartAndDueAddedAfterwards()
    {
        RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
        RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));

        DateTime start = DateTime.now();
        DateTime due = start.addDuration(new Duration(1, 1, 0));

        assertThat(new Seq<>(
                new Put<>(taskList, new EmptyRowData<TaskLists>()),
                new Put<>(task, new TitleData("Test")),
                new Put<>(task, new TimeData(start, due))
        ), resultsIn(mClient,
                new Assert<>(task, new TimeData(start, due)),
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task, new AllOf(
                        new EqArg(Instances.INSTANCE_START, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, due.getTimestamp()),
                        new EqArg(Instances.INSTANCE_START_SORTING, start.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, due.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DURATION, due.getTimestamp() - start.getTimestamp()),
                        new EqArg(Tasks.TZ, start.isAllDay() ? "UTC" : start.getTimeZone().getID())
                ))
@@ -230,12 +369,51 @@ public class TaskProviderTest
                        new EqArg(Instances.INSTANCE_START, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, start.addDuration(duration).getTimestamp()),
                        new EqArg(Instances.INSTANCE_DURATION, durationMillis),
                        new EqArg(Instances.INSTANCE_START_SORTING, start.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, start.addDuration(duration).shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()),
                        new EqArg(Tasks.TZ, "UTC")
                ))
        ));
    }


    /**
     * Create task with start and duration, check datetime values including generated due.
     */
    @Test
    public void testInsertWithStartAndDurationChangeTimeZone()
    {
        RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
        RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));

        DateTime start = DateTime.now();
        Duration duration = Duration.parse("PT1H");
        long durationMillis = duration.toMillis();
        DateTime startNew = start.shiftTimeZone(TimeZone.getTimeZone("America/New_York"));

        assertThat(new Seq<>(
                new Put<>(taskList, new EmptyRowData<TaskLists>()),
                new Put<>(task, new TimeData(start, duration)),
                // update the task with a the same start in a different time zone
                new Put<>(task, new TimeData(startNew, duration))

        ), resultsIn(mClient,
                new Assert<>(task, new TimeData(startNew, duration)),
                // note that, apart from the time zone, all values stay the same
                new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task, new AllOf(
                        new EqArg(Instances.INSTANCE_START, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, start.addDuration(duration).getTimestamp()),
                        new EqArg(Instances.INSTANCE_DURATION, durationMillis),
                        new EqArg(Instances.INSTANCE_START_SORTING, start.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, start.addDuration(duration).shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()),
                        new EqArg(Tasks.TZ, "America/New_York")
                ))
        ));
    }


    /**
     * Having a task with start and due.
     * Update it with different due, check datetime values correct in Tasks and Instances.
@@ -267,6 +445,9 @@ public class TaskProviderTest
                        new EqArg(Instances.INSTANCE_START, start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DUE, due2.getTimestamp()),
                        new EqArg(Instances.INSTANCE_DURATION, due2.getTimestamp() - start.getTimestamp()),
                        new EqArg(Instances.INSTANCE_START_SORTING, start.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_DUE_SORTING, due2.shiftTimeZone(TimeZone.getDefault()).getInstance()),
                        new EqArg(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()),
                        new EqArg(Tasks.TZ, "UTC")
                ))
        ));
+239 −256
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
    /**
     * The database version.
     */
    static final int DATABASE_VERSION = 16;
    private static final int DATABASE_VERSION = 17;


    /**
@@ -111,7 +111,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper

    }

    // @formatter:off

    /**
     * SQL command to create a view that combines tasks with some data from the list they belong to.
@@ -145,13 +144,11 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
            " on (" + Tables.TASKS + "." + Tasks.LIST_ID + "=" + Tables.LISTS + "." + TaskLists._ID + ") " +
            "left join " + Tables.PROPERTIES + " on (" + Tables.TASKS + "." + Tasks._ID + "=" + Tables.PROPERTIES + "." + Properties.TASK_ID + ");";


    /**
     * SQL command to drop the task view.
     */
    private final static String SQL_DROP_TASK_VIEW = "DROP VIEW " + Tables.TASKS_VIEW + ";";


    /**
     * SQL command to create a view that combines task instances with some data from the list they belong to.
     */
@@ -169,7 +166,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
            + " JOIN " + Tables.LISTS + " ON (" + Tables.TASKS + "." + TaskContract.Tasks.LIST_ID + "=" + Tables.LISTS + "." + TaskContract.Tasks._ID + ")"
            + " JOIN " + Tables.INSTANCES + " ON (" + Tables.TASKS + "." + TaskContract.Tasks._ID + "=" + Tables.INSTANCES + "." + TaskContract.Instances.TASK_ID + ");";


    /**
     * SQL command to create a view that combines task instances view with the belonging properties.
     */
@@ -189,7 +185,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
            + " JOIN " + Tables.INSTANCES + " ON (" + Tables.TASKS + "." + TaskContract.Tasks._ID + "=" + Tables.INSTANCES + "." + TaskContract.Instances.TASK_ID + ")"
            + " LEFT JOIN " + Tables.PROPERTIES + " ON (" + Tables.TASKS + "." + Tasks._ID + "=" + Tables.PROPERTIES + "." + Properties.TASK_ID + ");";


    /**
     * SQL command to create a view that combines task instances with some data from the list they belong to.
     */
@@ -209,13 +204,11 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
            + " JOIN " + Tables.INSTANCES + " ON (" + Tables.TASKS + "." + TaskContract.Tasks._ID + "=" + Tables.INSTANCES + "." + TaskContract.Instances.TASK_ID + ")"
            + " LEFT JOIN " + Tables.CATEGORIES_MAPPING + " ON (" + Tables.CATEGORIES_MAPPING + "." + CategoriesMapping.TASK_ID + "=" + Tables.INSTANCES + "." + TaskContract.Instances.TASK_ID + ");";


    /**
     * SQL command to drop the instance view.
     */
    private final static String SQL_DROP_INSTANCE_VIEW = "DROP VIEW " + Tables.INSTANCE_VIEW + ";";


    /**
     * SQL command to drop the instance property view.
     */
@@ -232,7 +225,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + TaskContract.SyncState.DATA + " TEXT "
                    + ");";


    /**
     * SQL command to create the instances table.
     */
@@ -244,8 +236,8 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + TaskContract.Instances.INSTANCE_DUE + " INTEGER, "
                    + TaskContract.Instances.INSTANCE_START_SORTING + " INTEGER, "
                    + TaskContract.Instances.INSTANCE_DUE_SORTING + " INTEGER, "
          + TaskContract.Instances.INSTANCE_DURATION + " INTEGER);";

                    + TaskContract.Instances.INSTANCE_DURATION + " INTEGER, "
                    + TaskContract.Instances.INSTANCE_ORIGINAL_TIME + " INTEGER DEFAULT 0);";

    /**
     * SQL command to create a trigger to clean up data of removed tasks.
@@ -272,7 +264,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
    private final static String SQL_DROP_TASKS_CLEANUP_TRIGGER =
            "DROP TRIGGER task_cleanup_trigger;";


    /**
     * SQL command that counts and sets the alarm on deletion
     */
@@ -314,8 +305,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
            "CREATE TRIGGER alarm_count_delete_trigger AFTER DELETE ON " + Tables.PROPERTIES + " WHEN OLD." + Properties.MIMETYPE + " = '" + Alarm.CONTENT_ITEM_TYPE + "'"
                    + SQL_COUNT_ALARMS_ON_DELETE;



    /**
     * SQL command to create a trigger to clean up data of removed property.
     */
@@ -325,7 +314,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + " DELETE FROM " + Tables.ALARMS + " WHERE " + TaskContract.Alarms.ALARM_ID + "= OLD." + TaskContract.Properties.PROPERTY_ID + ";"
                    + " END;";


    /**
     * SQL command to create a trigger to clean up data of removed property.
     */
@@ -335,8 +323,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + " DELETE FROM " + Tables.CATEGORIES_MAPPING + " WHERE " + CategoriesMapping.PROPERTY_ID + "= OLD." + TaskContract.Properties.PROPERTY_ID + ";"
                    + " END;";



    /**
     * SQL command to create a trigger to clean up property data of removed task.
     */
@@ -345,8 +331,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + " DELETE FROM " + Tables.PROPERTIES + " WHERE " + Properties.TASK_ID + "= OLD." + Tasks._ID + ";"
                    + " END;";



    /**
     * SQL command to create the task list table.
     */
@@ -373,7 +357,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + TaskContract.TaskLists.SYNC7 + " TEXT,"
                    + TaskContract.TaskLists.SYNC8 + " TEXT);";


    /**
     * SQL command to create the task table.
     */
@@ -429,7 +412,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + TaskContract.Tasks.SYNC7 + " TEXT,"
                    + TaskContract.Tasks.SYNC8 + " TEXT);";


    /**
     * SQL command to create the categories table.
     */
@@ -453,7 +435,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + "FOREIGN KEY (" + CategoriesMapping.PROPERTY_ID + ") REFERENCES " + Tables.PROPERTIES + "(" + TaskContract.Properties.PROPERTY_ID + "),"
                    + "FOREIGN KEY (" + CategoriesMapping.CATEGORY_ID + ") REFERENCES " + Tables.CATEGORIES + "(" + TaskContract.Categories._ID + "));";


    /**
     * SQL command to create the alarms table the stores the already triggered alarms.
     */
@@ -463,7 +444,6 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + TaskContract.Alarms.LAST_TRIGGER + " TEXT,"
                    + TaskContract.Alarms.NEXT_TRIGGER + " TEXT);";


    /**
     * SQL command to create the table for extended properties.
     */
@@ -498,16 +478,12 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                    + TaskContract.Properties.SYNC7 + " TEXT,"
                    + TaskContract.Properties.SYNC8 + " TEXT);";


    /**
     * SQL command to drop the task view.
     */
    private final static String SQL_DROP_PROPERTIES_TABLE = "DROP TABLE " + Tables.PROPERTIES + ";";


    // @formatter:on


    /**
     * Builds a string that creates an index on the given table for the given columns.
     *
@@ -617,6 +593,7 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
                TaskContract.Instances.INSTANCE_DUE));
        db.execSQL(createIndexString(Tables.INSTANCES, false, TaskContract.Instances.INSTANCE_START_SORTING));
        db.execSQL(createIndexString(Tables.INSTANCES, false, TaskContract.Instances.INSTANCE_DUE_SORTING));
        db.execSQL(createIndexString(Tables.INSTANCES, false, TaskContract.Instances.INSTANCE_ORIGINAL_TIME));
        db.execSQL(createIndexString(Tables.LISTS, false, TaskContract.TaskLists.ACCOUNT_NAME, // not sure if necessary
                TaskContract.TaskLists.ACCOUNT_TYPE));
        db.execSQL(createIndexString(Tables.TASKS, false, TaskContract.Tasks.STATUS, TaskContract.Tasks.LIST_ID, TaskContract.Tasks._SYNC_ID));
@@ -784,6 +761,12 @@ public class TaskDatabaseHelper extends SQLiteOpenHelper
            db.execSQL(createIndexString(Tables.INSTANCES, false, TaskContract.Instances.INSTANCE_DUE_SORTING));
        }

        if (oldVersion < 17)
        {
            db.execSQL("alter table " + Tables.INSTANCES + " add column " + TaskContract.Instances.INSTANCE_ORIGINAL_TIME + " integer default 0;");
            db.execSQL(createIndexString(Tables.INSTANCES, false, TaskContract.Instances.INSTANCE_ORIGINAL_TIME));
        }

        // upgrade FTS
        FTSDatabaseHelper.onUpgrade(db, oldVersion, newVersion);

Loading