Remove unused database columns

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

@ -2,11 +2,11 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 83, "version": 83,
"identityHash": "63f86a7965511d8f19651de927905a5f", "identityHash": "cf081f859d693597f29288a63f13bbf7",
"entities": [ "entities": [
{ {
"tableName": "notification", "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": [ "fields": [
{ {
"fieldPath": "uid", "fieldPath": "uid",
@ -56,7 +56,19 @@
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_notification_task` ON `${TABLE_NAME}` (`task`)" "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", "tableName": "tagdata",
@ -216,7 +228,7 @@
}, },
{ {
"tableName": "task_list_metadata", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -224,12 +236,6 @@
"affinity": "INTEGER", "affinity": "INTEGER",
"notNull": false "notNull": false
}, },
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{ {
"fieldPath": "tagUuid", "fieldPath": "tagUuid",
"columnName": "tag_uuid", "columnName": "tag_uuid",
@ -260,7 +266,7 @@
}, },
{ {
"tableName": "tasks", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -346,24 +352,12 @@
"affinity": "INTEGER", "affinity": "INTEGER",
"notNull": true "notNull": true
}, },
{
"fieldPath": "reminderPeriod",
"columnName": "notifications",
"affinity": "INTEGER",
"notNull": true
},
{ {
"fieldPath": "reminderLast", "fieldPath": "reminderLast",
"columnName": "lastNotified", "columnName": "lastNotified",
"affinity": "INTEGER", "affinity": "INTEGER",
"notNull": true "notNull": true
}, },
{
"fieldPath": "reminderSnooze",
"columnName": "snoozeTime",
"affinity": "INTEGER",
"notNull": true
},
{ {
"fieldPath": "recurrence", "fieldPath": "recurrence",
"columnName": "recurrence", "columnName": "recurrence",
@ -399,12 +393,6 @@
"columnName": "parent", "columnName": "parent",
"affinity": "INTEGER", "affinity": "INTEGER",
"notNull": true "notNull": true
},
{
"fieldPath": "parentUuid",
"columnName": "parent_uuid",
"affinity": "TEXT",
"notNull": false
} }
], ],
"primaryKey": { "primaryKey": {
@ -439,7 +427,7 @@
}, },
{ {
"tableName": "alarms", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -487,8 +475,30 @@
], ],
"autoGenerate": true "autoGenerate": true
}, },
"indices": [], "indices": [
"foreignKeys": [] {
"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", "tableName": "places",
@ -589,7 +599,7 @@
}, },
{ {
"tableName": "geofences", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -630,20 +640,32 @@
}, },
"indices": [ "indices": [
{ {
"name": "geo_task", "name": "index_geofences_task",
"unique": false, "unique": false,
"columnNames": [ "columnNames": [
"task" "task"
], ],
"orders": [], "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", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -684,20 +706,32 @@
}, },
"indices": [ "indices": [
{ {
"name": "tag_task", "name": "index_tags_task",
"unique": false, "unique": false,
"columnNames": [ "columnNames": [
"task" "task"
], ],
"orders": [], "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", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -774,26 +808,38 @@
}, },
"indices": [ "indices": [
{ {
"name": "gt_task", "name": "gt_list_parent",
"unique": false, "unique": false,
"columnNames": [ "columnNames": [
"gt_task" "gt_list_id",
"gt_parent"
], ],
"orders": [], "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, "unique": false,
"columnNames": [ "columnNames": [
"gt_list_id", "gt_task"
"gt_parent"
], ],
"orders": [], "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", "tableName": "filters",
@ -995,7 +1041,7 @@
}, },
{ {
"tableName": "caldav_tasks", "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": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -1066,16 +1112,28 @@
}, },
"indices": [ "indices": [
{ {
"name": "cd_task", "name": "index_caldav_tasks_cd_task",
"unique": false, "unique": false,
"columnNames": [ "columnNames": [
"cd_task" "cd_task"
], ],
"orders": [], "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", "tableName": "caldav_accounts",
@ -1365,7 +1423,7 @@
"views": [], "views": [],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "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.HiltAndroidTest
import dagger.hilt.android.testing.UninstallModules import dagger.hilt.android.testing.UninstallModules
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.junit.Assert.* import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.tasks.data.CaldavAccount 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.CALENDAR
import org.tasks.makers.CaldavTaskMaker.ETAG import org.tasks.makers.CaldavTaskMaker.ETAG
import org.tasks.makers.CaldavTaskMaker.OBJECT import org.tasks.makers.CaldavTaskMaker.OBJECT
import org.tasks.makers.CaldavTaskMaker.TASK
import org.tasks.makers.CaldavTaskMaker.newCaldavTask import org.tasks.makers.CaldavTaskMaker.newCaldavTask
import org.tasks.makers.TaskMaker.newTask
@UninstallModules(ProductionModule::class) @UninstallModules(ProductionModule::class)
@HiltAndroidTest @HiltAndroidTest
@ -62,9 +64,10 @@ class CaldavSynchronizerTest : CaldavTest() {
caldavDao.insert(this) caldavDao.insert(this)
} }
caldavDao.insert(newCaldavTask( caldavDao.insert(newCaldavTask(
with(OBJECT, "3164728546640386952.ics"), with(TASK, taskDao.insert(newTask())),
with(ETAG, "43b3ffaac5131880e4dd07a79adba82a"), with(OBJECT, "3164728546640386952.ics"),
with(CALENDAR, calendar.uuid) with(ETAG, "43b3ffaac5131880e4dd07a79adba82a"),
with(CALENDAR, calendar.uuid)
)) ))
enqueue(OC_SHARE_PROPFIND, OC_SHARE_REPORT) enqueue(OC_SHARE_PROPFIND, OC_SHARE_REPORT)

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

@ -84,18 +84,10 @@ class Task : Parcelable {
@SerializedName("ringFlags", alternate = ["reminderFlags"]) @SerializedName("ringFlags", alternate = ["reminderFlags"])
var ringFlags = 0 var ringFlags = 0
@Deprecated("old random reminders")
@ColumnInfo(name = "notifications")
var reminderPeriod = 0L
/** Unixtime the last reminder was triggered */ /** Unixtime the last reminder was triggered */
@ColumnInfo(name = "lastNotified") @ColumnInfo(name = "lastNotified")
var reminderLast = 0L var reminderLast = 0L
@Deprecated("old snooze reminders")
@ColumnInfo(name = "snoozeTime")
var reminderSnooze = 0L
@ColumnInfo(name = "recurrence") @ColumnInfo(name = "recurrence")
var recurrence: String? = null var recurrence: String? = null
@ -116,10 +108,6 @@ class Task : Parcelable {
@Transient @Transient
var parent = 0L var parent = 0L
@Deprecated(message = "no longer used")
@ColumnInfo(name = "parent_uuid")
var parentUuid: String? = null
@Ignore @Ignore
@Transient @Transient
private var transitoryData: HashMap<String, Any>? = null 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.LocalBroadcastManager
import org.tasks.R import org.tasks.R
import org.tasks.caldav.VtodoCache 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.AlarmDao
import org.tasks.data.CaldavDao import org.tasks.data.CaldavDao
import org.tasks.data.FilterDao import org.tasks.data.FilterDao
@ -160,11 +158,7 @@ class TasksJsonImporter @Inject constructor(
} }
if (version < V12_4) { if (version < V12_4) {
task.defaultReminders(task.ringFlags) task.defaultReminders(task.ringFlags)
task.randomReminder = task.reminderPeriod
alarmDao.insert(task.getDefaultAlarms()) alarmDao.insert(task.getDefaultAlarms())
task.reminderSnooze.takeIf { it > 0 }?.let {
alarmDao.insert(Alarm(task.id, it, TYPE_SNOOZE))
}
task.ringFlags = when { task.ringFlags = when {
task.isNotifyModeFive -> Task.NOTIFY_MODE_FIVE task.isNotifyModeFive -> Task.NOTIFY_MODE_FIVE
task.isNotifyModeNonstop -> Task.NOTIFY_MODE_NONSTOP task.isNotifyModeNonstop -> Task.NOTIFY_MODE_NONSTOP

@ -4,20 +4,32 @@ import android.os.Parcel
import android.os.Parcelable import android.os.Parcelable
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore import androidx.room.Ignore
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
import org.tasks.time.DateTimeUtils.printTimestamp import org.tasks.time.DateTimeUtils.printTimestamp
import java.util.concurrent.TimeUnit 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 { class Alarm : Parcelable {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id") @ColumnInfo(name = "_id")
@Transient @Transient
var id: Long = 0 var id: Long = 0
@ColumnInfo(name = "task") @ColumnInfo(name = "task", index = true)
@Transient @Transient
var task: Long = 0 var task: Long = 0

@ -2,20 +2,31 @@ package org.tasks.data
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
import com.todoroo.astrid.helper.UUIDHelper 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 { class CaldavTask {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cd_id") @ColumnInfo(name = "cd_id")
@Transient @Transient
var id: Long = 0 var id: Long = 0
@ColumnInfo(name = "cd_task") @ColumnInfo(name = "cd_task", index = true)
@Transient @Transient
var task: Long = 0 var task: Long = 0

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

@ -2,20 +2,35 @@ package org.tasks.data
import android.os.Parcel import android.os.Parcel
import android.os.Parcelable 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.andlib.data.Table
import com.todoroo.astrid.data.Task
import org.tasks.R import org.tasks.R
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import java.io.Serializable 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 { class Geofence : Serializable, Parcelable {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "geofence_id") @ColumnInfo(name = "geofence_id")
@Transient @Transient
var id: Long = 0 var id: Long = 0
@ColumnInfo(name = "task") @ColumnInfo(name = "task", index = true)
@Transient @Transient
var task: Long = 0 var task: Long = 0

@ -1,19 +1,35 @@
package org.tasks.data 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.andlib.data.Table
import com.todoroo.astrid.data.Task
@Entity(tableName = "google_tasks",
indices = [ @Entity(
Index(name = "gt_task", value = ["gt_task"]), tableName = "google_tasks",
Index(name = "gt_list_parent", value = ["gt_list_id", "gt_parent"])]) 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 { class GoogleTask {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gt_id") @ColumnInfo(name = "gt_id")
@Transient @Transient
var id: Long = 0 var id: Long = 0
@ColumnInfo(name = "gt_task") @ColumnInfo(name = "gt_task", index = true)
@Transient @Transient
var task: Long = 0 var task: Long = 0

@ -1,17 +1,32 @@
package org.tasks.data 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.andlib.data.Table
import com.todoroo.astrid.data.Task 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 { class Tag {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id") @ColumnInfo(name = "_id")
@Transient @Transient
var id: Long = 0 var id: Long = 0
@ColumnInfo(name = "task") @ColumnInfo(name = "task", index = true)
@Transient @Transient
var task: Long = 0 var task: Long = 0

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

@ -26,6 +26,10 @@ object Migrations {
@DeleteColumn.Entries( @DeleteColumn.Entries(
DeleteColumn(tableName = "geofences", columnName = "radius"), 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 class AutoMigrate82to83: AutoMigrationSpec

@ -2,11 +2,26 @@ package org.tasks.notifications
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index import androidx.room.Index
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
@Entity(tableName = Notification.TABLE_NAME, indices = [Index(value = ["task"], unique = true)])
@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 { class Notification {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "uid") @ColumnInfo(name = "uid")

Loading…
Cancel
Save