From 2c91b1148c8f1170f0bdabf7ebe9edb7a40a6343 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 27 Feb 2022 20:16:41 +0100 Subject: [PATCH] fix database migration to v29 (#2354) --- .../com.keylesspalace.tusky.db.AppDatabase/29.json | 8 ++++---- .../tusky/components/conversation/ConversationEntity.kt | 2 +- .../tusky/components/timeline/TimelineTypeMappers.kt | 2 +- .../main/java/com/keylesspalace/tusky/db/AppDatabase.java | 2 +- .../main/java/com/keylesspalace/tusky/entity/Status.kt | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/schemas/com.keylesspalace.tusky.db.AppDatabase/29.json b/app/schemas/com.keylesspalace.tusky.db.AppDatabase/29.json index 51fcfde7..ac6eb677 100644 --- a/app/schemas/com.keylesspalace.tusky.db.AppDatabase/29.json +++ b/app/schemas/com.keylesspalace.tusky.db.AppDatabase/29.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 29, - "identityHash": "d3643e2bf6d8a2efb13254a0ea3ab2a1", + "identityHash": "62c289344334da2db091ad4ba0a49c6a", "entities": [ { "tableName": "DraftEntity", @@ -610,7 +610,7 @@ }, { "tableName": "ConversationEntity", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `id` TEXT NOT NULL, `accounts` TEXT NOT NULL, `unread` INTEGER NOT NULL, `s_id` TEXT NOT NULL, `s_url` TEXT, `s_inReplyToId` TEXT, `s_inReplyToAccountId` TEXT, `s_account` TEXT NOT NULL, `s_content` TEXT NOT NULL, `s_createdAt` INTEGER NOT NULL, `s_emojis` TEXT NOT NULL, `s_favouritesCount` INTEGER NOT NULL, `s_favourited` INTEGER NOT NULL, `s_bookmarked` INTEGER NOT NULL, `s_sensitive` INTEGER NOT NULL, `s_spoilerText` TEXT NOT NULL, `s_attachments` TEXT NOT NULL, `s_mentions` TEXT NOT NULL, `s_tags` TEXT NOT NULL, `s_showingHiddenContent` INTEGER NOT NULL, `s_expanded` INTEGER NOT NULL, `s_collapsible` INTEGER NOT NULL, `s_collapsed` INTEGER NOT NULL, `s_muted` INTEGER NOT NULL, `s_poll` TEXT, PRIMARY KEY(`id`, `accountId`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `id` TEXT NOT NULL, `accounts` TEXT NOT NULL, `unread` INTEGER NOT NULL, `s_id` TEXT NOT NULL, `s_url` TEXT, `s_inReplyToId` TEXT, `s_inReplyToAccountId` TEXT, `s_account` TEXT NOT NULL, `s_content` TEXT NOT NULL, `s_createdAt` INTEGER NOT NULL, `s_emojis` TEXT NOT NULL, `s_favouritesCount` INTEGER NOT NULL, `s_favourited` INTEGER NOT NULL, `s_bookmarked` INTEGER NOT NULL, `s_sensitive` INTEGER NOT NULL, `s_spoilerText` TEXT NOT NULL, `s_attachments` TEXT NOT NULL, `s_mentions` TEXT NOT NULL, `s_tags` TEXT, `s_showingHiddenContent` INTEGER NOT NULL, `s_expanded` INTEGER NOT NULL, `s_collapsible` INTEGER NOT NULL, `s_collapsed` INTEGER NOT NULL, `s_muted` INTEGER NOT NULL, `s_poll` TEXT, PRIMARY KEY(`id`, `accountId`))", "fields": [ { "fieldPath": "accountId", @@ -730,7 +730,7 @@ "fieldPath": "lastStatus.tags", "columnName": "s_tags", "affinity": "TEXT", - "notNull": true + "notNull": false }, { "fieldPath": "lastStatus.showingHiddenContent", @@ -783,7 +783,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, 'd3643e2bf6d8a2efb13254a0ea3ab2a1')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '62c289344334da2db091ad4ba0a49c6a')" ] } } \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt index f96e98d2..8bb875e4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt @@ -80,7 +80,7 @@ data class ConversationStatusEntity( val spoilerText: String, val attachments: ArrayList, val mentions: List, - val tags: List, + val tags: List?, val showingHiddenContent: Boolean, val expanded: Boolean, val collapsible: Boolean, diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt index b57fa2d9..a121cb40 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt @@ -161,7 +161,7 @@ fun TimelineStatusWithAccount.toViewData(gson: Gson): StatusViewData { val attachments: ArrayList = gson.fromJson(status.attachments, attachmentArrayListType) ?: arrayListOf() val mentions: List = gson.fromJson(status.mentions, mentionListType) ?: emptyList() - val tags: List = gson.fromJson(status.tags, tagListType) ?: emptyList() + val tags: List? = gson.fromJson(status.tags, tagListType) val application = gson.fromJson(status.application, Status.Application::class.java) val emojis: List = gson.fromJson(status.emojis, emojisListType) ?: emptyList() val poll: Poll? = gson.fromJson(status.poll, Poll::class.java) diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java index 269ee0a9..b97b8254 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java +++ b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java @@ -461,7 +461,7 @@ public abstract class AppDatabase extends RoomDatabase { public static final Migration MIGRATION_28_29 = new Migration(28, 29) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { - database.execSQL("ALTER TABLE `ConversationEntity` ADD COLUMN `s_tags` TEXT NOT NULL"); + database.execSQL("ALTER TABLE `ConversationEntity` ADD COLUMN `s_tags` TEXT"); database.execSQL("ALTER TABLE `TimelineStatusEntity` ADD COLUMN `tags` TEXT"); } }; diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index 50643b56..7a54655f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -42,7 +42,7 @@ data class Status( val visibility: Visibility, @SerializedName("media_attachments") var attachments: ArrayList, val mentions: List, - val tags: List, + val tags: List?, val application: Application?, val pinned: Boolean?, val muted: Boolean?,