Remove unused database columns

pull/1796/head
Alex Baker 3 years ago
parent f512b8291b
commit 323fa0eb8a

@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 83,
"identityHash": "63f86a7965511d8f19651de927905a5f",
"identityHash": "cf081f859d693597f29288a63f13bbf7",
"entities": [
{
"tableName": "notification",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `type` INTEGER NOT NULL, `location` INTEGER)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `type` INTEGER NOT NULL, `location` INTEGER, FOREIGN KEY(`task`) REFERENCES `tasks`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "uid",
@ -56,7 +56,19 @@
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_notification_task` ON `${TABLE_NAME}` (`task`)"
}
],
"foreignKeys": []
"foreignKeys": [
{
"table": "tasks",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"task"
],
"referencedColumns": [
"_id"
]
}
]
},
{
"tableName": "tagdata",
@ -216,7 +228,7 @@
},
{
"tableName": "task_list_metadata",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `tag_uuid` TEXT, `filter` TEXT, `task_ids` TEXT)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `tag_uuid` TEXT, `filter` TEXT, `task_ids` TEXT)",
"fields": [
{
"fieldPath": "id",
@ -224,12 +236,6 @@
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tagUuid",
"columnName": "tag_uuid",
@ -260,7 +266,7 @@
},
{
"tableName": "tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `importance` INTEGER NOT NULL, `dueDate` INTEGER NOT NULL, `hideUntil` INTEGER NOT NULL, `created` INTEGER NOT NULL, `modified` INTEGER NOT NULL, `completed` INTEGER NOT NULL, `deleted` INTEGER NOT NULL, `notes` TEXT, `estimatedSeconds` INTEGER NOT NULL, `elapsedSeconds` INTEGER NOT NULL, `timerStart` INTEGER NOT NULL, `notificationFlags` INTEGER NOT NULL, `notifications` INTEGER NOT NULL, `lastNotified` INTEGER NOT NULL, `snoozeTime` INTEGER NOT NULL, `recurrence` TEXT, `repeatUntil` INTEGER NOT NULL, `calendarUri` TEXT, `remoteId` TEXT, `collapsed` INTEGER NOT NULL, `parent` INTEGER NOT NULL, `parent_uuid` TEXT)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `importance` INTEGER NOT NULL, `dueDate` INTEGER NOT NULL, `hideUntil` INTEGER NOT NULL, `created` INTEGER NOT NULL, `modified` INTEGER NOT NULL, `completed` INTEGER NOT NULL, `deleted` INTEGER NOT NULL, `notes` TEXT, `estimatedSeconds` INTEGER NOT NULL, `elapsedSeconds` INTEGER NOT NULL, `timerStart` INTEGER NOT NULL, `notificationFlags` INTEGER NOT NULL, `lastNotified` INTEGER NOT NULL, `recurrence` TEXT, `repeatUntil` INTEGER NOT NULL, `calendarUri` TEXT, `remoteId` TEXT, `collapsed` INTEGER NOT NULL, `parent` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
@ -346,24 +352,12 @@
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "reminderPeriod",
"columnName": "notifications",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "reminderLast",
"columnName": "lastNotified",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "reminderSnooze",
"columnName": "snoozeTime",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "recurrence",
"columnName": "recurrence",
@ -399,12 +393,6 @@
"columnName": "parent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "parentUuid",
"columnName": "parent_uuid",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
@ -439,7 +427,7 @@
},
{
"tableName": "alarms",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `time` INTEGER NOT NULL, `type` INTEGER NOT NULL DEFAULT 0, `repeat` INTEGER NOT NULL DEFAULT 0, `interval` INTEGER NOT NULL DEFAULT 0)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `time` INTEGER NOT NULL, `type` INTEGER NOT NULL DEFAULT 0, `repeat` INTEGER NOT NULL DEFAULT 0, `interval` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`task`) REFERENCES `tasks`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@ -487,8 +475,30 @@
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
"indices": [
{
"name": "index_alarms_task",
"unique": false,
"columnNames": [
"task"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_alarms_task` ON `${TABLE_NAME}` (`task`)"
}
],
"foreignKeys": [
{
"table": "tasks",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"task"
],
"referencedColumns": [
"_id"
]
}
]
},
{
"tableName": "places",
@ -589,7 +599,7 @@
},
{
"tableName": "geofences",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`geofence_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `place` TEXT, `arrival` INTEGER NOT NULL, `departure` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`geofence_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `place` TEXT, `arrival` INTEGER NOT NULL, `departure` INTEGER NOT NULL, FOREIGN KEY(`task`) REFERENCES `tasks`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@ -630,20 +640,32 @@
},
"indices": [
{
"name": "geo_task",
"name": "index_geofences_task",
"unique": false,
"columnNames": [
"task"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `geo_task` ON `${TABLE_NAME}` (`task`)"
"createSql": "CREATE INDEX IF NOT EXISTS `index_geofences_task` ON `${TABLE_NAME}` (`task`)"
}
],
"foreignKeys": []
"foreignKeys": [
{
"table": "tasks",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"task"
],
"referencedColumns": [
"_id"
]
}
]
},
{
"tableName": "tags",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `name` TEXT, `tag_uid` TEXT, `task_uid` TEXT)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `name` TEXT, `tag_uid` TEXT, `task_uid` TEXT, FOREIGN KEY(`task`) REFERENCES `tasks`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@ -684,20 +706,32 @@
},
"indices": [
{
"name": "tag_task",
"name": "index_tags_task",
"unique": false,
"columnNames": [
"task"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `tag_task` ON `${TABLE_NAME}` (`task`)"
"createSql": "CREATE INDEX IF NOT EXISTS `index_tags_task` ON `${TABLE_NAME}` (`task`)"
}
],
"foreignKeys": []
"foreignKeys": [
{
"table": "tasks",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"task"
],
"referencedColumns": [
"_id"
]
}
]
},
{
"tableName": "google_tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`gt_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `gt_task` INTEGER NOT NULL, `gt_remote_id` TEXT, `gt_list_id` TEXT, `gt_parent` INTEGER NOT NULL, `gt_remote_parent` TEXT, `gt_moved` INTEGER NOT NULL, `gt_order` INTEGER NOT NULL, `gt_remote_order` INTEGER NOT NULL, `gt_last_sync` INTEGER NOT NULL, `gt_deleted` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`gt_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `gt_task` INTEGER NOT NULL, `gt_remote_id` TEXT, `gt_list_id` TEXT, `gt_parent` INTEGER NOT NULL, `gt_remote_parent` TEXT, `gt_moved` INTEGER NOT NULL, `gt_order` INTEGER NOT NULL, `gt_remote_order` INTEGER NOT NULL, `gt_last_sync` INTEGER NOT NULL, `gt_deleted` INTEGER NOT NULL, FOREIGN KEY(`gt_task`) REFERENCES `tasks`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@ -774,26 +808,38 @@
},
"indices": [
{
"name": "gt_task",
"name": "gt_list_parent",
"unique": false,
"columnNames": [
"gt_task"
"gt_list_id",
"gt_parent"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `gt_task` ON `${TABLE_NAME}` (`gt_task`)"
"createSql": "CREATE INDEX IF NOT EXISTS `gt_list_parent` ON `${TABLE_NAME}` (`gt_list_id`, `gt_parent`)"
},
{
"name": "gt_list_parent",
"name": "index_google_tasks_gt_task",
"unique": false,
"columnNames": [
"gt_list_id",
"gt_parent"
"gt_task"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `gt_list_parent` ON `${TABLE_NAME}` (`gt_list_id`, `gt_parent`)"
"createSql": "CREATE INDEX IF NOT EXISTS `index_google_tasks_gt_task` ON `${TABLE_NAME}` (`gt_task`)"
}
],
"foreignKeys": []
"foreignKeys": [
{
"table": "tasks",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"gt_task"
],
"referencedColumns": [
"_id"
]
}
]
},
{
"tableName": "filters",
@ -995,7 +1041,7 @@
},
{
"tableName": "caldav_tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cd_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `cd_task` INTEGER NOT NULL, `cd_calendar` TEXT, `cd_object` TEXT, `cd_remote_id` TEXT, `cd_etag` TEXT, `cd_last_sync` INTEGER NOT NULL, `cd_deleted` INTEGER NOT NULL, `cd_remote_parent` TEXT, `cd_order` INTEGER)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cd_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `cd_task` INTEGER NOT NULL, `cd_calendar` TEXT, `cd_object` TEXT, `cd_remote_id` TEXT, `cd_etag` TEXT, `cd_last_sync` INTEGER NOT NULL, `cd_deleted` INTEGER NOT NULL, `cd_remote_parent` TEXT, `cd_order` INTEGER, FOREIGN KEY(`cd_task`) REFERENCES `tasks`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@ -1066,16 +1112,28 @@
},
"indices": [
{
"name": "cd_task",
"name": "index_caldav_tasks_cd_task",
"unique": false,
"columnNames": [
"cd_task"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `cd_task` ON `${TABLE_NAME}` (`cd_task`)"
"createSql": "CREATE INDEX IF NOT EXISTS `index_caldav_tasks_cd_task` ON `${TABLE_NAME}` (`cd_task`)"
}
],
"foreignKeys": []
"foreignKeys": [
{
"table": "tasks",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"cd_task"
],
"referencedColumns": [
"_id"
]
}
]
},
{
"tableName": "caldav_accounts",
@ -1365,7 +1423,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '63f86a7965511d8f19651de927905a5f')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'cf081f859d693597f29288a63f13bbf7')"
]
}
}

@ -5,7 +5,7 @@ import com.todoroo.astrid.helper.UUIDHelper
import dagger.hilt.android.testing.HiltAndroidTest
import dagger.hilt.android.testing.UninstallModules
import kotlinx.coroutines.runBlocking
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.tasks.data.CaldavAccount
@ -14,7 +14,9 @@ import org.tasks.injection.ProductionModule
import org.tasks.makers.CaldavTaskMaker.CALENDAR
import org.tasks.makers.CaldavTaskMaker.ETAG
import org.tasks.makers.CaldavTaskMaker.OBJECT
import org.tasks.makers.CaldavTaskMaker.TASK
import org.tasks.makers.CaldavTaskMaker.newCaldavTask
import org.tasks.makers.TaskMaker.newTask
@UninstallModules(ProductionModule::class)
@HiltAndroidTest
@ -62,9 +64,10 @@ class CaldavSynchronizerTest : CaldavTest() {
caldavDao.insert(this)
}
caldavDao.insert(newCaldavTask(
with(OBJECT, "3164728546640386952.ics"),
with(ETAG, "43b3ffaac5131880e4dd07a79adba82a"),
with(CALENDAR, calendar.uuid)
with(TASK, taskDao.insert(newTask())),
with(OBJECT, "3164728546640386952.ics"),
with(ETAG, "43b3ffaac5131880e4dd07a79adba82a"),
with(CALENDAR, calendar.uuid)
))
enqueue(OC_SHARE_PROPFIND, OC_SHARE_REPORT)

@ -58,7 +58,7 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun getPreviousIsNullForTopTask() = runBlocking {
googleTaskDao.insertAndShift(newGoogleTask(), true)
insert(newGoogleTask())
assertNull(googleTaskDao.getPrevious("1", 0, 0))
}
@ -93,21 +93,21 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun getTaskFromRemoteId() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(REMOTE_ID, "1234"), with(TASK, 4)))
assertEquals(4L, googleTaskDao.getTask("1234"))
insert(newGoogleTask(with(REMOTE_ID, "1234")))
assertEquals(1L, googleTaskDao.getTask("1234"))
}
@Test
fun getRemoteIdForTask() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(REMOTE_ID, "1234"), with(TASK, 4)))
assertEquals("1234", googleTaskDao.getRemoteId(4L))
insert(newGoogleTask(with(REMOTE_ID, "1234")))
assertEquals("1234", googleTaskDao.getRemoteId(1L))
}
@Test
fun moveDownInList() = runBlocking {
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "1")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "2")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "3")), false)
insert(newGoogleTask(with(REMOTE_ID, "1")))
insert(newGoogleTask(with(REMOTE_ID, "2")))
insert(newGoogleTask(with(REMOTE_ID, "3")))
val two = getByRemoteId("2")
googleTaskDao.move(two, 0, 0)
assertEquals(0, googleTaskDao.getByRemoteId("2")!!.order)
@ -117,9 +117,9 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun moveUpInList() = runBlocking {
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "1")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "2")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "3")), false)
insert(newGoogleTask(with(REMOTE_ID, "1")))
insert(newGoogleTask(with(REMOTE_ID, "2")))
insert(newGoogleTask(with(REMOTE_ID, "3")))
val one = getByRemoteId("1")
googleTaskDao.move(one, 0, 1)
assertEquals(0, googleTaskDao.getByRemoteId("2")!!.order)
@ -129,9 +129,9 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun moveToTop() = runBlocking {
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "1")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "2")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "3")), false)
insert(newGoogleTask(with(REMOTE_ID, "1")))
insert(newGoogleTask(with(REMOTE_ID, "2")))
insert(newGoogleTask(with(REMOTE_ID, "3")))
val three = getByRemoteId("3")
googleTaskDao.move(three, 0, 0)
assertEquals(0, googleTaskDao.getByRemoteId("3")!!.order)
@ -141,9 +141,9 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun moveToBottom() = runBlocking {
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "1")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "2")), false)
googleTaskDao.insertAndShift(newGoogleTask(with(REMOTE_ID, "3")), false)
insert(newGoogleTask(with(REMOTE_ID, "1")))
insert(newGoogleTask(with(REMOTE_ID, "2")))
insert(newGoogleTask(with(REMOTE_ID, "3")))
val one = getByRemoteId("1")
googleTaskDao.move(one, 0, 2)
assertEquals(0, googleTaskDao.getByRemoteId("2")!!.order)
@ -153,14 +153,14 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun findChildrenInList() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(PARENT, 1L)))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(PARENT, 1L)))
assertEquals(listOf(2L), googleTaskDao.getChildren(listOf(1L, 2L)))
}
@Test
fun dontAllowEmptyParent() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "1234")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "1234")))
googleTaskDao.updatePosition("1234", "", "0")
@ -169,7 +169,7 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun updatePositionWithNullParent() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "1234")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "1234")))
googleTaskDao.updatePosition("1234", null, "0")
@ -178,7 +178,7 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun updatePosition() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "1234")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "1234")))
googleTaskDao.updatePosition("1234", "abcd", "0")
@ -187,8 +187,8 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun updateParents() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_PARENT, "123")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_PARENT, "123")))
googleTaskDao.updateParents()
@ -197,8 +197,8 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun updateParentsByList() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_PARENT, "123")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_PARENT, "123")))
googleTaskDao.updateParents("1")
@ -207,8 +207,8 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun updateParentsMustMatchList() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "2"), with(REMOTE_PARENT, "123")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "2"), with(REMOTE_PARENT, "123")))
googleTaskDao.updateParents()
@ -217,8 +217,8 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun updateParentsByListMustMatchList() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "2"), with(REMOTE_PARENT, "123")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "123")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "2"), with(REMOTE_PARENT, "123")))
googleTaskDao.updateParents("2")
@ -227,8 +227,8 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun ignoreEmptyStringWhenUpdatingParents() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_ID, ""), with(REMOTE_PARENT, "")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_ID, ""), with(REMOTE_PARENT, "")))
googleTaskDao.updateParents()
@ -237,8 +237,8 @@ class GoogleTaskDaoTests : InjectingTestCase() {
@Test
fun ignoreEmptyStringWhenUpdatingParentsForList() = runBlocking {
googleTaskDao.insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "")))
googleTaskDao.insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_ID, ""), with(REMOTE_PARENT, "")))
insert(newGoogleTask(with(TASK, 1), with(LIST, "1"), with(REMOTE_ID, "")))
insert(newGoogleTask(with(TASK, 2), with(LIST, "1"), with(REMOTE_ID, ""), with(REMOTE_PARENT, "")))
googleTaskDao.updateParents("1")
@ -253,7 +253,7 @@ class GoogleTaskDaoTests : InjectingTestCase() {
insert(googleTask, false)
}
private suspend fun insert(googleTask: GoogleTask, top: Boolean) {
private suspend fun insert(googleTask: GoogleTask, top: Boolean = false) {
val task = newTask()
taskDao.createNew(task)
googleTask.task = task.id

@ -84,18 +84,10 @@ class Task : Parcelable {
@SerializedName("ringFlags", alternate = ["reminderFlags"])
var ringFlags = 0
@Deprecated("old random reminders")
@ColumnInfo(name = "notifications")
var reminderPeriod = 0L
/** Unixtime the last reminder was triggered */
@ColumnInfo(name = "lastNotified")
var reminderLast = 0L
@Deprecated("old snooze reminders")
@ColumnInfo(name = "snoozeTime")
var reminderSnooze = 0L
@ColumnInfo(name = "recurrence")
var recurrence: String? = null
@ -116,10 +108,6 @@ class Task : Parcelable {
@Transient
var parent = 0L
@Deprecated(message = "no longer used")
@ColumnInfo(name = "parent_uuid")
var parentUuid: String? = null
@Ignore
@Transient
private var transitoryData: HashMap<String, Any>? = null

@ -17,8 +17,6 @@ import com.todoroo.astrid.service.Upgrader.Companion.getAndroidColor
import org.tasks.LocalBroadcastManager
import org.tasks.R
import org.tasks.caldav.VtodoCache
import org.tasks.data.Alarm
import org.tasks.data.Alarm.Companion.TYPE_SNOOZE
import org.tasks.data.AlarmDao
import org.tasks.data.CaldavDao
import org.tasks.data.FilterDao
@ -160,11 +158,7 @@ class TasksJsonImporter @Inject constructor(
}
if (version < V12_4) {
task.defaultReminders(task.ringFlags)
task.randomReminder = task.reminderPeriod
alarmDao.insert(task.getDefaultAlarms())
task.reminderSnooze.takeIf { it > 0 }?.let {
alarmDao.insert(Alarm(task.id, it, TYPE_SNOOZE))
}
task.ringFlags = when {
task.isNotifyModeFive -> Task.NOTIFY_MODE_FIVE
task.isNotifyModeNonstop -> Task.NOTIFY_MODE_NONSTOP

@ -4,20 +4,32 @@ import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
import org.tasks.time.DateTimeUtils.printTimestamp
import java.util.concurrent.TimeUnit
@Entity(tableName = Alarm.TABLE_NAME)
@Entity(
tableName = Alarm.TABLE_NAME,
foreignKeys = [
ForeignKey(
entity = Task::class,
parentColumns = ["_id"],
childColumns = ["task"],
onDelete = ForeignKey.CASCADE
)
]
)
class Alarm : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "task")
@ColumnInfo(name = "task", index = true)
@Transient
var task: Long = 0

@ -2,20 +2,31 @@ package org.tasks.data
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
import com.todoroo.astrid.helper.UUIDHelper
@Entity(tableName = "caldav_tasks", indices = [Index(name = "cd_task", value = ["cd_task"])])
@Entity(
tableName = "caldav_tasks",
foreignKeys = [
ForeignKey(
entity = Task::class,
parentColumns = ["_id"],
childColumns = ["cd_task"],
onDelete = ForeignKey.CASCADE,
),
]
)
class CaldavTask {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cd_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "cd_task")
@ColumnInfo(name = "cd_task", index = true)
@Transient
var task: Long = 0

@ -10,21 +10,6 @@ import org.tasks.db.SuspendDbUtils.eachChunk
@Dao
abstract class DeletionDao {
@Query("DELETE FROM caldav_tasks WHERE cd_task IN(:ids)")
internal abstract suspend fun deleteCaldavTasks(ids: List<Long>)
@Query("DELETE FROM google_tasks WHERE gt_task IN(:ids)")
internal abstract suspend fun deleteGoogleTasks(ids: List<Long>)
@Query("DELETE FROM tags WHERE task IN(:ids)")
internal abstract suspend fun deleteTags(ids: List<Long>)
@Query("DELETE FROM geofences WHERE task IN(:ids)")
internal abstract suspend fun deleteGeofences(ids: List<Long>)
@Query("DELETE FROM alarms WHERE task IN(:ids)")
internal abstract suspend fun deleteAlarms(ids: List<Long>)
@Query("DELETE FROM tasks WHERE _id IN(:ids)")
internal abstract suspend fun deleteTasks(ids: List<Long>)
@ -57,11 +42,6 @@ WHERE recurring = 1
@Transaction
open suspend fun delete(ids: List<Long>) {
ids.eachChunk {
deleteAlarms(it)
deleteGeofences(it)
deleteTags(it)
deleteGoogleTasks(it)
deleteCaldavTasks(it)
deleteTasks(it)
}
}

@ -2,20 +2,35 @@ package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.room.*
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
import org.tasks.R
import org.tasks.preferences.Preferences
import java.io.Serializable
@Entity(tableName = Geofence.TABLE_NAME, indices = [Index(name = "geo_task", value = ["task"])])
@Entity(
tableName = Geofence.TABLE_NAME,
foreignKeys = [
ForeignKey(
entity = Task::class,
parentColumns = ["_id"],
childColumns = ["task"],
onDelete = ForeignKey.CASCADE,
),
]
)
class Geofence : Serializable, Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "geofence_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "task")
@ColumnInfo(name = "task", index = true)
@Transient
var task: Long = 0

@ -1,19 +1,35 @@
package org.tasks.data
import androidx.room.*
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
@Entity(tableName = "google_tasks",
indices = [
Index(name = "gt_task", value = ["gt_task"]),
Index(name = "gt_list_parent", value = ["gt_list_id", "gt_parent"])])
import com.todoroo.astrid.data.Task
@Entity(
tableName = "google_tasks",
indices = [
Index(name = "gt_list_parent", value = ["gt_list_id", "gt_parent"])
],
foreignKeys = [
ForeignKey(
entity = Task::class,
parentColumns = ["_id"],
childColumns = ["gt_task"],
onDelete = ForeignKey.CASCADE,
),
]
)
class GoogleTask {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gt_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "gt_task")
@ColumnInfo(name = "gt_task", index = true)
@Transient
var task: Long = 0

@ -1,17 +1,32 @@
package org.tasks.data
import androidx.room.*
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
@Entity(tableName = "tags", indices = [Index(name = "tag_task", value = ["task"])])
@Entity(
tableName = "tags",
foreignKeys = [
ForeignKey(
entity = Task::class,
parentColumns = ["_id"],
childColumns = ["task"],
onDelete = ForeignKey.CASCADE,
),
]
)
class Tag {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "task")
@ColumnInfo(name = "task", index = true)
@Transient
var task: Long = 0

@ -17,10 +17,6 @@ class TaskListMetadata {
@Transient
var id: Long? = null
@Deprecated("not used")
@ColumnInfo(name = "remoteId")
var remoteId: String? = Task.NO_UUID
@ColumnInfo(name = "tag_uuid")
var tagUuid: String? = Task.NO_UUID

@ -26,6 +26,10 @@ object Migrations {
@DeleteColumn.Entries(
DeleteColumn(tableName = "geofences", columnName = "radius"),
DeleteColumn(tableName = "task_list_metadata", columnName = "remoteId"),
DeleteColumn(tableName = "tasks", columnName = "snoozeTime"),
DeleteColumn(tableName = "tasks", columnName = "parent_uuid"),
DeleteColumn(tableName = "tasks", columnName = "notifications"),
)
class AutoMigrate82to83: AutoMigrationSpec

@ -2,11 +2,26 @@ package org.tasks.notifications
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
@Entity(tableName = Notification.TABLE_NAME, indices = [Index(value = ["task"], unique = true)])
import com.todoroo.astrid.data.Task
@Entity(
tableName = Notification.TABLE_NAME,
indices = [
Index(value = ["task"], unique = true)
],
foreignKeys = [
ForeignKey(
entity = Task::class,
parentColumns = ["_id"],
childColumns = ["task"],
onDelete = ForeignKey.CASCADE,
)
]
)
class Notification {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "uid")

Loading…
Cancel
Save