Fold the 1.4.0 schema changes into one migration (#79, #101)

This commit is contained in:
makiolaj committed 2026-11-20 11:57:57 +01:00
1 parent b71f75dcd2
commit d6425124ee
5 files changed
+271 -1062

No files matched your search

@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 7,
"identityHash": "6b4e1394949216ad24168835d260a73f",
"identityHash": "774919dbed9faffbddd3358514b60bdd",
"entities": [
{
"tableName": "accounts",
@@ -770,11 +770,273 @@
]
}
]
},
{
"tableName": "advanced_deleted",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `copy_id` INTEGER NOT NULL, `anchor` INTEGER NOT NULL, `alarms` TEXT NOT NULL DEFAULT '', `row_id` INTEGER NOT NULL, `row_list_id` INTEGER NOT NULL, `row_uid` TEXT NOT NULL, `row_href` TEXT, `row_etag` TEXT, `row_title` TEXT, `row_description` TEXT, `row_location` TEXT, `row_url` TEXT, `row_color` INTEGER, `row_categories` TEXT NOT NULL DEFAULT '', `row_status` INTEGER NOT NULL DEFAULT 0, `row_percent_complete` INTEGER, `row_completed_at` INTEGER, `row_priority` INTEGER NOT NULL DEFAULT 0, `row_classification` INTEGER, `row_dtstart` INTEGER, `row_due` INTEGER, `row_duration` TEXT, `row_is_all_day` INTEGER NOT NULL DEFAULT 0, `row_untimed` TEXT, `row_timezone` TEXT, `row_rrule` TEXT, `row_rdate` TEXT, `row_exdate` TEXT, `row_recurrence_id` INTEGER, `row_master_id` INTEGER, `row_parent_id` INTEGER, `row_sort_order` INTEGER NOT NULL DEFAULT 0, `row_created_at` INTEGER, `row_last_modified` INTEGER, `row_sequence` INTEGER NOT NULL DEFAULT 0, `row_is_dirty` INTEGER NOT NULL DEFAULT 0, `row_is_deleted` INTEGER NOT NULL DEFAULT 0, `row_unknown_properties` TEXT, `row_reminders_off` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`copy_id`) REFERENCES `advanced_occurrences`(`copy_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "copyId",
"columnName": "copy_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "anchor",
"columnName": "anchor",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "alarms",
"columnName": "alarms",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
},
{
"fieldPath": "row.id",
"columnName": "row_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "row.listId",
"columnName": "row_list_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "row.uid",
"columnName": "row_uid",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "row.href",
"columnName": "row_href",
"affinity": "TEXT"
},
{
"fieldPath": "row.etag",
"columnName": "row_etag",
"affinity": "TEXT"
},
{
"fieldPath": "row.title",
"columnName": "row_title",
"affinity": "TEXT"
},
{
"fieldPath": "row.description",
"columnName": "row_description",
"affinity": "TEXT"
},
{
"fieldPath": "row.location",
"columnName": "row_location",
"affinity": "TEXT"
},
{
"fieldPath": "row.url",
"columnName": "row_url",
"affinity": "TEXT"
},
{
"fieldPath": "row.color",
"columnName": "row_color",
"affinity": "INTEGER"
},
{
"fieldPath": "row.categories",
"columnName": "row_categories",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
},
{
"fieldPath": "row.status",
"columnName": "row_status",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.percentComplete",
"columnName": "row_percent_complete",
"affinity": "INTEGER"
},
{
"fieldPath": "row.completedAt",
"columnName": "row_completed_at",
"affinity": "INTEGER"
},
{
"fieldPath": "row.priority",
"columnName": "row_priority",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.classification",
"columnName": "row_classification",
"affinity": "INTEGER"
},
{
"fieldPath": "row.dtstart",
"columnName": "row_dtstart",
"affinity": "INTEGER"
},
{
"fieldPath": "row.due",
"columnName": "row_due",
"affinity": "INTEGER"
},
{
"fieldPath": "row.duration",
"columnName": "row_duration",
"affinity": "TEXT"
},
{
"fieldPath": "row.isAllDay",
"columnName": "row_is_all_day",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.untimed",
"columnName": "row_untimed",
"affinity": "TEXT"
},
{
"fieldPath": "row.timezone",
"columnName": "row_timezone",
"affinity": "TEXT"
},
{
"fieldPath": "row.rrule",
"columnName": "row_rrule",
"affinity": "TEXT"
},
{
"fieldPath": "row.rdate",
"columnName": "row_rdate",
"affinity": "TEXT"
},
{
"fieldPath": "row.exdate",
"columnName": "row_exdate",
"affinity": "TEXT"
},
{
"fieldPath": "row.recurrenceId",
"columnName": "row_recurrence_id",
"affinity": "INTEGER"
},
{
"fieldPath": "row.masterId",
"columnName": "row_master_id",
"affinity": "INTEGER"
},
{
"fieldPath": "row.parentId",
"columnName": "row_parent_id",
"affinity": "INTEGER"
},
{
"fieldPath": "row.sortOrder",
"columnName": "row_sort_order",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.createdAt",
"columnName": "row_created_at",
"affinity": "INTEGER"
},
{
"fieldPath": "row.lastModified",
"columnName": "row_last_modified",
"affinity": "INTEGER"
},
{
"fieldPath": "row.sequence",
"columnName": "row_sequence",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.isDirty",
"columnName": "row_is_dirty",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.isDeleted",
"columnName": "row_is_deleted",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "row.unknownProperties",
"columnName": "row_unknown_properties",
"affinity": "TEXT"
},
{
"fieldPath": "row.remindersOff",
"columnName": "row_reminders_off",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_advanced_deleted_copy_id",
"unique": false,
"columnNames": [
"copy_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_advanced_deleted_copy_id` ON `${TABLE_NAME}` (`copy_id`)"
}
],
"foreignKeys": [
{
"table": "advanced_occurrences",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"copy_id"
],
"referencedColumns": [
"copy_id"
]
}
]
}
],
"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, '6b4e1394949216ad24168835d260a73f')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '774919dbed9faffbddd3358514b60bdd')"
]
}
}
File diff suppressed because it is too large. Load diff
@@ -194,7 +194,7 @@ class TasksDatabaseMigrationTest {
}
@Test
fun leavesExistingTasksWithBothEndsAsTheyWere() {
fun keepsExistingTasksAndAddsAnEmptyTableForDeletedOverrides() {
helper.createDatabase(TEST_DB, 6).use { db ->
db.execSQL("INSERT INTO task_lists (id, name, color) VALUES (1, 'Personal', 0)")
db.execSQL("INSERT INTO tasks (id, list_id, uid, dtstart, due, is_all_day) VALUES (1, 1, 'a', 0, 3600000, 0)")
@@ -207,14 +207,6 @@ class TasksDatabaseMigrationTest {
assertThat(c.getLong(1)).isEqualTo(0L)
assertThat(c.getLong(2)).isEqualTo(3_600_000L)
}
}
}
@Test
fun addsAnEmptyTableForDeletedOverrides() {
helper.createDatabase(TEST_DB, 7).close()
helper.runMigrationsAndValidate(TEST_DB, 8, true, TasksDatabase.MIGRATION_7_8).use { db ->
db.query("SELECT COUNT(*) FROM advanced_deleted").use { c ->
assertThat(c.moveToFirst()).isTrue()
assertThat(c.getInt(0)).isEqualTo(0)
@@ -89,7 +89,7 @@ object DataProvideModule {
// backed-up `.db` does not. The backup rules carry all three files and
// the app checkpoints on ON_STOP.
.setJournalMode(RoomDatabase.JournalMode.WRITE_AHEAD_LOGGING)
.addMigrations(TasksDatabase.MIGRATION_1_2, TasksDatabase.MIGRATION_2_3, TasksDatabase.MIGRATION_3_4, TasksDatabase.MIGRATION_4_5, TasksDatabase.MIGRATION_5_6, TasksDatabase.MIGRATION_6_7, TasksDatabase.MIGRATION_7_8)
.addMigrations(TasksDatabase.MIGRATION_1_2, TasksDatabase.MIGRATION_2_3, TasksDatabase.MIGRATION_3_4, TasksDatabase.MIGRATION_4_5, TasksDatabase.MIGRATION_5_6, TasksDatabase.MIGRATION_6_7)
.build()
/**
@@ -25,7 +25,7 @@ import kotlin.time.Instant
AdvancedDetachedEntity::class,
AdvancedDeletedEntity::class,
],
version = 8,
version = 7,
exportSchema = true,
)
@TypeConverters(Converters::class)
@@ -213,16 +213,13 @@ abstract class TasksDatabase : RoomDatabase() {
}
}
/** v7 lets one end of a timed task go without a time (#101). */
/**
* v7 lets one end of a timed task go without a time (#101) and keeps the open overrides a tick
* repeating from completion deleted, for its undo (#79).
*/
val MIGRATION_6_7 = object : Migration(6, 7) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE tasks ADD COLUMN `untimed` TEXT")
}
}
/** v8 keeps the open overrides a tick repeating from completion deleted, for its undo (#79). */
val MIGRATION_7_8 = object : Migration(7, 8) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL(
"CREATE TABLE IF NOT EXISTS `advanced_deleted` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `copy_id` INTEGER NOT NULL, `anchor` INTEGER NOT NULL, `alarms` TEXT NOT NULL DEFAULT '', `row_id` INTEGER NOT NULL, `row_list_id` INTEGER NOT NULL, `row_uid` TEXT NOT NULL, `row_href` TEXT, `row_etag` TEXT, `row_title` TEXT, `row_description` TEXT, `row_location` TEXT, `row_url` TEXT, `row_color` INTEGER, `row_categories` TEXT NOT NULL DEFAULT '', `row_status` INTEGER NOT NULL DEFAULT 0, `row_percent_complete` INTEGER, `row_completed_at` INTEGER, `row_priority` INTEGER NOT NULL DEFAULT 0, `row_classification` INTEGER, `row_dtstart` INTEGER, `row_due` INTEGER, `row_duration` TEXT, `row_is_all_day` INTEGER NOT NULL DEFAULT 0, `row_untimed` TEXT, `row_timezone` TEXT, `row_rrule` TEXT, `row_rdate` TEXT, `row_exdate` TEXT, `row_recurrence_id` INTEGER, `row_master_id` INTEGER, `row_parent_id` INTEGER, `row_sort_order` INTEGER NOT NULL DEFAULT 0, `row_created_at` INTEGER, `row_last_modified` INTEGER, `row_sequence` INTEGER NOT NULL DEFAULT 0, `row_is_dirty` INTEGER NOT NULL DEFAULT 0, `row_is_deleted` INTEGER NOT NULL DEFAULT 0, `row_unknown_properties` TEXT, `row_reminders_off` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`copy_id`) REFERENCES `advanced_occurrences`(`copy_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
)