From 775b1a15b76eb6da433317cb2222fa926c61df8a Mon Sep 17 00:00:00 2001 From: Yuichiro Kinoshita Date: Sat, 7 Sep 2024 17:47:43 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20SQLite=E4=B8=8A=E3=81=AB=E3=82=AD?= =?UTF-8?q?=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5=E3=81=AE=E3=83=9E=E3=83=83?= =?UTF-8?q?=E3=83=94=E3=83=B3=E3=82=B0=E3=82=92=E6=8C=81=E3=81=A4=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../73.json | 4883 +++++++++++++++++ .../milktea/data/di/module/DbModule.kt | 4 + .../milktea/data/infrastructure/DataBase.kt | 9 +- .../infrastructure/image/ImageCacheDAO.kt | 52 + .../infrastructure/image/ImageCacheEntity.kt | 52 + .../image/ImageCacheRepositoryImpl.kt | 87 +- 6 files changed, 5018 insertions(+), 69 deletions(-) create mode 100644 modules/data/schemas/net.pantasystem.milktea.data.infrastructure.DataBase/73.json create mode 100644 modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheDAO.kt create mode 100644 modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheEntity.kt diff --git a/modules/data/schemas/net.pantasystem.milktea.data.infrastructure.DataBase/73.json b/modules/data/schemas/net.pantasystem.milktea.data.infrastructure.DataBase/73.json new file mode 100644 index 0000000000..f15e20b76c --- /dev/null +++ b/modules/data/schemas/net.pantasystem.milktea.data.infrastructure.DataBase/73.json @@ -0,0 +1,4883 @@ +{ + "formatVersion": 1, + "database": { + "version": 73, + "identityHash": "88a9400e4ded90d995fe9d03585f39bc", + "entities": [ + { + "tableName": "reaction_history", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`reaction` TEXT NOT NULL, `instance_domain` TEXT NOT NULL, `accountId` INTEGER, `target_post_id` TEXT, `target_user_id` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT)", + "fields": [ + { + "fieldPath": "reaction", + "columnName": "reaction", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "instanceDomain", + "columnName": "instance_domain", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "targetPostId", + "columnName": "target_post_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "targetUserId", + "columnName": "target_user_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "reaction_user_setting", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`reaction` TEXT NOT NULL, `instance_domain` TEXT NOT NULL, `weight` INTEGER NOT NULL, PRIMARY KEY(`reaction`, `instance_domain`))", + "fields": [ + { + "fieldPath": "reaction", + "columnName": "reaction", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "instanceDomain", + "columnName": "instance_domain", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "weight", + "columnName": "weight", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "reaction", + "instance_domain" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "poll_choice_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`choice` TEXT NOT NULL, `draft_note_id` INTEGER NOT NULL, `weight` INTEGER NOT NULL, PRIMARY KEY(`choice`, `weight`, `draft_note_id`), FOREIGN KEY(`draft_note_id`) REFERENCES `draft_note_table`(`draft_note_id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "choice", + "columnName": "choice", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "draftNoteId", + "columnName": "draft_note_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "weight", + "columnName": "weight", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "choice", + "weight", + "draft_note_id" + ] + }, + "indices": [ + { + "name": "index_poll_choice_table_draft_note_id_choice", + "unique": false, + "columnNames": [ + "draft_note_id", + "choice" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_poll_choice_table_draft_note_id_choice` ON `${TABLE_NAME}` (`draft_note_id`, `choice`)" + } + ], + "foreignKeys": [ + { + "table": "draft_note_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "draft_note_id" + ], + "referencedColumns": [ + "draft_note_id" + ] + } + ] + }, + { + "tableName": "user_id", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`userId` TEXT NOT NULL, `draft_note_id` INTEGER NOT NULL, PRIMARY KEY(`userId`, `draft_note_id`), FOREIGN KEY(`draft_note_id`) REFERENCES `draft_note_table`(`draft_note_id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "draftNoteId", + "columnName": "draft_note_id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "userId", + "draft_note_id" + ] + }, + "indices": [ + { + "name": "index_user_id_draft_note_id", + "unique": false, + "columnNames": [ + "draft_note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_id_draft_note_id` ON `${TABLE_NAME}` (`draft_note_id`)" + } + ], + "foreignKeys": [ + { + "table": "draft_note_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "draft_note_id" + ], + "referencedColumns": [ + "draft_note_id" + ] + } + ] + }, + { + "tableName": "draft_note_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `visibility` TEXT NOT NULL, `text` TEXT, `cw` TEXT, `viaMobile` INTEGER, `localOnly` INTEGER, `noExtractMentions` INTEGER, `noExtractHashtags` INTEGER, `noExtractEmojis` INTEGER, `replyId` TEXT, `renoteId` TEXT, `channelId` TEXT, `scheduleWillPostAt` TEXT, `draft_note_id` INTEGER PRIMARY KEY AUTOINCREMENT, `isSensitive` INTEGER, `reactionAcceptanceType` TEXT, `multiple` INTEGER, `expiresAt` INTEGER, FOREIGN KEY(`accountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "visibility", + "columnName": "visibility", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "cw", + "columnName": "cw", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "viaMobile", + "columnName": "viaMobile", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "localOnly", + "columnName": "localOnly", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "noExtractMentions", + "columnName": "noExtractMentions", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "noExtractHashtags", + "columnName": "noExtractHashtags", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "noExtractEmojis", + "columnName": "noExtractEmojis", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "replyId", + "columnName": "replyId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "renoteId", + "columnName": "renoteId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "channelId", + "columnName": "channelId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "scheduleWillPostAt", + "columnName": "scheduleWillPostAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "draftNoteId", + "columnName": "draft_note_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "isSensitive", + "columnName": "isSensitive", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "reactionAcceptanceType", + "columnName": "reactionAcceptanceType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "poll.multiple", + "columnName": "multiple", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "poll.expiresAt", + "columnName": "expiresAt", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "draft_note_id" + ] + }, + "indices": [ + { + "name": "index_draft_note_table_accountId_text", + "unique": false, + "columnNames": [ + "accountId", + "text" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_draft_note_table_accountId_text` ON `${TABLE_NAME}` (`accountId`, `text`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "url_preview", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`url` TEXT NOT NULL, `title` TEXT NOT NULL, `icon` TEXT, `description` TEXT, `thumbnail` TEXT, `siteName` TEXT, `createdAt` TEXT, PRIMARY KEY(`url`))", + "fields": [ + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "icon", + "columnName": "icon", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "thumbnail", + "columnName": "thumbnail", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "siteName", + "columnName": "siteName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "url" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "account_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`remoteId` TEXT NOT NULL, `instanceDomain` TEXT NOT NULL, `userName` TEXT NOT NULL, `encryptedToken` TEXT NOT NULL, `instanceType` TEXT NOT NULL DEFAULT 'misskey', `accountId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "remoteId", + "columnName": "remoteId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "instanceDomain", + "columnName": "instanceDomain", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userName", + "columnName": "userName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "encryptedToken", + "columnName": "encryptedToken", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "instanceType", + "columnName": "instanceType", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "'misskey'" + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "accountId" + ] + }, + "indices": [ + { + "name": "index_account_table_remoteId", + "unique": false, + "columnNames": [ + "remoteId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_account_table_remoteId` ON `${TABLE_NAME}` (`remoteId`)" + }, + { + "name": "index_account_table_instanceDomain", + "unique": false, + "columnNames": [ + "instanceDomain" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_account_table_instanceDomain` ON `${TABLE_NAME}` (`instanceDomain`)" + }, + { + "name": "index_account_table_userName", + "unique": false, + "columnNames": [ + "userName" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_account_table_userName` ON `${TABLE_NAME}` (`userName`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "page_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `title` TEXT NOT NULL, `weight` INTEGER NOT NULL, `isSavePagePosition` INTEGER, `attachedAccountId` INTEGER, `pageId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` TEXT NOT NULL, `withFiles` INTEGER, `excludeNsfw` INTEGER, `includeLocalRenotes` INTEGER, `includeMyRenotes` INTEGER, `includeRenotedMyRenotes` INTEGER, `listId` TEXT, `following` INTEGER, `visibility` TEXT, `noteId` TEXT, `tag` TEXT, `reply` INTEGER, `renote` INTEGER, `poll` INTEGER, `offset` INTEGER, `markAsRead` INTEGER, `userId` TEXT, `includeReplies` INTEGER, `query` TEXT, `host` TEXT, `antennaId` TEXT, `channelId` TEXT, `clipId` TEXT, `excludeReplies` INTEGER, `excludeReposts` INTEGER, `excludeIfExistsSensitiveMedia` INTEGER)", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "weight", + "columnName": "weight", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isSavePagePosition", + "columnName": "isSavePagePosition", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "attachedAccountId", + "columnName": "attachedAccountId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageId", + "columnName": "pageId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "pageParams.type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "pageParams.withFiles", + "columnName": "withFiles", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.excludeNsfw", + "columnName": "excludeNsfw", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.includeLocalRenotes", + "columnName": "includeLocalRenotes", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.includeMyRenotes", + "columnName": "includeMyRenotes", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.includeRenotedMyRenotes", + "columnName": "includeRenotedMyRenotes", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.listId", + "columnName": "listId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.following", + "columnName": "following", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.visibility", + "columnName": "visibility", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.noteId", + "columnName": "noteId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.tag", + "columnName": "tag", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.reply", + "columnName": "reply", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.renote", + "columnName": "renote", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.poll", + "columnName": "poll", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.offset", + "columnName": "offset", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.markAsRead", + "columnName": "markAsRead", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.includeReplies", + "columnName": "includeReplies", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.query", + "columnName": "query", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.host", + "columnName": "host", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.antennaId", + "columnName": "antennaId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.channelId", + "columnName": "channelId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.clipId", + "columnName": "clipId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pageParams.excludeReplies", + "columnName": "excludeReplies", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.excludeReposts", + "columnName": "excludeReposts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pageParams.excludeIfExistsSensitiveMedia", + "columnName": "excludeIfExistsSensitiveMedia", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "pageId" + ] + }, + "indices": [ + { + "name": "index_page_table_weight", + "unique": false, + "columnNames": [ + "weight" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_page_table_weight` ON `${TABLE_NAME}` (`weight`)" + }, + { + "name": "index_page_table_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_page_table_accountId` ON `${TABLE_NAME}` (`accountId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "meta_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uri` TEXT NOT NULL, `bannerUrl` TEXT, `cacheRemoteFiles` INTEGER, `description` TEXT, `disableGlobalTimeline` INTEGER, `disableLocalTimeline` INTEGER, `disableRegistration` INTEGER, `driveCapacityPerLocalUserMb` INTEGER, `driveCapacityPerRemoteUserMb` INTEGER, `enableDiscordIntegration` INTEGER, `enableEmail` INTEGER, `enableEmojiReaction` INTEGER, `enableGithubIntegration` INTEGER, `enableRecaptcha` INTEGER, `enableServiceWorker` INTEGER, `enableTwitterIntegration` INTEGER, `errorImageUrl` TEXT, `feedbackUrl` TEXT, `iconUrl` TEXT, `maintainerEmail` TEXT, `maintainerName` TEXT, `mascotImageUrl` TEXT, `maxNoteTextLength` INTEGER, `name` TEXT, `recaptchaSiteKey` TEXT, `secure` INTEGER, `swPublicKey` TEXT, `toSUrl` TEXT, `version` TEXT NOT NULL, PRIMARY KEY(`uri`))", + "fields": [ + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "bannerUrl", + "columnName": "bannerUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "cacheRemoteFiles", + "columnName": "cacheRemoteFiles", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "disableGlobalTimeline", + "columnName": "disableGlobalTimeline", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "disableLocalTimeline", + "columnName": "disableLocalTimeline", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "disableRegistration", + "columnName": "disableRegistration", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driveCapacityPerLocalUserMb", + "columnName": "driveCapacityPerLocalUserMb", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driveCapacityPerRemoteUserMb", + "columnName": "driveCapacityPerRemoteUserMb", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableDiscordIntegration", + "columnName": "enableDiscordIntegration", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableEmail", + "columnName": "enableEmail", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableEmojiReaction", + "columnName": "enableEmojiReaction", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableGithubIntegration", + "columnName": "enableGithubIntegration", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableRecaptcha", + "columnName": "enableRecaptcha", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableServiceWorker", + "columnName": "enableServiceWorker", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "enableTwitterIntegration", + "columnName": "enableTwitterIntegration", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "errorImageUrl", + "columnName": "errorImageUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "feedbackUrl", + "columnName": "feedbackUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "iconUrl", + "columnName": "iconUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "maintainerEmail", + "columnName": "maintainerEmail", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "maintainerName", + "columnName": "maintainerName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "mascotImageUrl", + "columnName": "mascotImageUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "maxNoteTextLength", + "columnName": "maxNoteTextLength", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "recaptchaSiteKey", + "columnName": "recaptchaSiteKey", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "secure", + "columnName": "secure", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "swPublicKey", + "columnName": "swPublicKey", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "toSUrl", + "columnName": "toSUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "uri" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "unread_notifications_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `notificationId` TEXT NOT NULL, PRIMARY KEY(`accountId`, `notificationId`), FOREIGN KEY(`accountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "notificationId", + "columnName": "notificationId", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountId", + "notificationId" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "nicknames", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`nickname` TEXT NOT NULL, `username` TEXT NOT NULL, `host` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "nickname", + "columnName": "nickname", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userName", + "columnName": "username", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "host", + "columnName": "host", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_nicknames_username_host", + "unique": true, + "columnNames": [ + "username", + "host" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_nicknames_username_host` ON `${TABLE_NAME}` (`username`, `host`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "drive_file_v1", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` TEXT NOT NULL, `relatedAccountId` INTEGER NOT NULL, `createdAt` TEXT, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `md5` TEXT, `size` INTEGER, `url` TEXT NOT NULL, `isSensitive` INTEGER NOT NULL, `thumbnailUrl` TEXT, `folderId` TEXT, `userId` TEXT, `comment` TEXT, `blurhash` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`relatedAccountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "serverId", + "columnName": "serverId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "relatedAccountId", + "columnName": "relatedAccountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "size", + "columnName": "size", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isSensitive", + "columnName": "isSensitive", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "thumbnailUrl", + "columnName": "thumbnailUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "folderId", + "columnName": "folderId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "comment", + "columnName": "comment", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "blurhash", + "columnName": "blurhash", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_drive_file_v1_serverId_relatedAccountId", + "unique": true, + "columnNames": [ + "serverId", + "relatedAccountId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_drive_file_v1_serverId_relatedAccountId` ON `${TABLE_NAME}` (`serverId`, `relatedAccountId`)" + }, + { + "name": "index_drive_file_v1_serverId", + "unique": false, + "columnNames": [ + "serverId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_drive_file_v1_serverId` ON `${TABLE_NAME}` (`serverId`)" + }, + { + "name": "index_drive_file_v1_relatedAccountId", + "unique": false, + "columnNames": [ + "relatedAccountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_drive_file_v1_relatedAccountId` ON `${TABLE_NAME}` (`relatedAccountId`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "relatedAccountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "draft_file_v2_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`draftNoteId` INTEGER NOT NULL, `filePropertyId` INTEGER, `localFileId` INTEGER, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`filePropertyId`) REFERENCES `drive_file_v1`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL , FOREIGN KEY(`localFileId`) REFERENCES `draft_local_file_v2_table`(`localFileId`) ON UPDATE NO ACTION ON DELETE SET NULL )", + "fields": [ + { + "fieldPath": "draftNoteId", + "columnName": "draftNoteId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "filePropertyId", + "columnName": "filePropertyId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "localFileId", + "columnName": "localFileId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_draft_file_v2_table_draftNoteId_filePropertyId_localFileId", + "unique": true, + "columnNames": [ + "draftNoteId", + "filePropertyId", + "localFileId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_draft_file_v2_table_draftNoteId_filePropertyId_localFileId` ON `${TABLE_NAME}` (`draftNoteId`, `filePropertyId`, `localFileId`)" + }, + { + "name": "index_draft_file_v2_table_draftNoteId", + "unique": false, + "columnNames": [ + "draftNoteId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_draft_file_v2_table_draftNoteId` ON `${TABLE_NAME}` (`draftNoteId`)" + }, + { + "name": "index_draft_file_v2_table_localFileId", + "unique": false, + "columnNames": [ + "localFileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_draft_file_v2_table_localFileId` ON `${TABLE_NAME}` (`localFileId`)" + }, + { + "name": "index_draft_file_v2_table_filePropertyId", + "unique": false, + "columnNames": [ + "filePropertyId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_draft_file_v2_table_filePropertyId` ON `${TABLE_NAME}` (`filePropertyId`)" + } + ], + "foreignKeys": [ + { + "table": "drive_file_v1", + "onDelete": "SET NULL", + "onUpdate": "NO ACTION", + "columns": [ + "filePropertyId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "draft_local_file_v2_table", + "onDelete": "SET NULL", + "onUpdate": "NO ACTION", + "columns": [ + "localFileId" + ], + "referencedColumns": [ + "localFileId" + ] + } + ] + }, + { + "tableName": "draft_local_file_v2_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `file_path` TEXT NOT NULL, `is_sensitive` INTEGER, `type` TEXT NOT NULL, `thumbnailUrl` TEXT, `folder_id` TEXT, `file_size` INTEGER, `comment` TEXT, `localFileId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "filePath", + "columnName": "file_path", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isSensitive", + "columnName": "is_sensitive", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "thumbnailUrl", + "columnName": "thumbnailUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "folderId", + "columnName": "folder_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "fileSize", + "columnName": "file_size", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "comment", + "columnName": "comment", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "localFileId", + "columnName": "localFileId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "localFileId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "group_v1", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `createdAt` TEXT NOT NULL, `name` TEXT NOT NULL, `ownerId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`accountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "serverId", + "columnName": "serverId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "ownerId", + "columnName": "ownerId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_group_v1_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_group_v1_accountId` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "index_group_v1_serverId", + "unique": false, + "columnNames": [ + "serverId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_group_v1_serverId` ON `${TABLE_NAME}` (`serverId`)" + }, + { + "name": "index_group_v1_accountId_serverId", + "unique": true, + "columnNames": [ + "accountId", + "serverId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_group_v1_accountId_serverId` ON `${TABLE_NAME}` (`accountId`, `serverId`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "group_member_v1", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` INTEGER NOT NULL, `userId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`groupId`) REFERENCES `group_v1`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "groupId", + "columnName": "groupId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_group_member_v1_groupId", + "unique": false, + "columnNames": [ + "groupId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_group_member_v1_groupId` ON `${TABLE_NAME}` (`groupId`)" + }, + { + "name": "index_group_member_v1_groupId_userId", + "unique": true, + "columnNames": [ + "groupId", + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_group_member_v1_groupId_userId` ON `${TABLE_NAME}` (`groupId`, `userId`)" + } + ], + "foreignKeys": [ + { + "table": "group_v1", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "groupId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "user", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `userName` TEXT NOT NULL, `name` TEXT, `avatarUrl` TEXT, `isCat` INTEGER, `isBot` INTEGER, `host` TEXT NOT NULL, `isSameHost` INTEGER NOT NULL, `avatarBlurhash` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`accountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "serverId", + "columnName": "serverId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userName", + "columnName": "userName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "avatarUrl", + "columnName": "avatarUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isCat", + "columnName": "isCat", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "isBot", + "columnName": "isBot", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "host", + "columnName": "host", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isSameHost", + "columnName": "isSameHost", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "avatarBlurhash", + "columnName": "avatarBlurhash", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_user_serverId_accountId", + "unique": true, + "columnNames": [ + "serverId", + "accountId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_serverId_accountId` ON `${TABLE_NAME}` (`serverId`, `accountId`)" + }, + { + "name": "index_user_userName", + "unique": false, + "columnNames": [ + "userName" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_userName` ON `${TABLE_NAME}` (`userName`)" + }, + { + "name": "index_user_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_accountId` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "index_user_host", + "unique": false, + "columnNames": [ + "host" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_host` ON `${TABLE_NAME}` (`host`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "user_detailed_state", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`description` TEXT, `followersCount` INTEGER, `followingCount` INTEGER, `hostLower` TEXT, `notesCount` INTEGER, `bannerUrl` TEXT, `url` TEXT, `isFollowing` INTEGER NOT NULL, `isFollower` INTEGER NOT NULL, `isBlocking` INTEGER NOT NULL, `isMuting` INTEGER NOT NULL, `hasPendingFollowRequestFromYou` INTEGER NOT NULL, `hasPendingFollowRequestToYou` INTEGER NOT NULL, `isLocked` INTEGER NOT NULL, `birthday` TEXT, `createdAt` TEXT, `updatedAt` TEXT, `publicReactions` INTEGER, `userId` INTEGER NOT NULL, PRIMARY KEY(`userId`), FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "followersCount", + "columnName": "followersCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "followingCount", + "columnName": "followingCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "hostLower", + "columnName": "hostLower", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "notesCount", + "columnName": "notesCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bannerUrl", + "columnName": "bannerUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isFollowing", + "columnName": "isFollowing", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isFollower", + "columnName": "isFollower", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isBlocking", + "columnName": "isBlocking", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isMuting", + "columnName": "isMuting", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasPendingFollowRequestFromYou", + "columnName": "hasPendingFollowRequestFromYou", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasPendingFollowRequestToYou", + "columnName": "hasPendingFollowRequestToYou", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isLocked", + "columnName": "isLocked", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "birthday", + "columnName": "birthday", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "updatedAt", + "columnName": "updatedAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "publicReactions", + "columnName": "publicReactions", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "userId" + ] + }, + "indices": [ + { + "name": "index_user_detailed_state_userId", + "unique": true, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_detailed_state_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "user_emoji", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `url` TEXT, `uri` TEXT, `userId` INTEGER NOT NULL, `aspectRatio` REAL, `cachePath` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "aspectRatio", + "columnName": "aspectRatio", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "cachePath", + "columnName": "cachePath", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_user_emoji_name_userId", + "unique": true, + "columnNames": [ + "name", + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_emoji_name_userId` ON `${TABLE_NAME}` (`name`, `userId`)" + }, + { + "name": "index_user_emoji_userId", + "unique": false, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_emoji_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "pinned_note_id", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteId` TEXT NOT NULL, `userId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "noteId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_pinned_note_id_noteId_userId", + "unique": true, + "columnNames": [ + "noteId", + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_pinned_note_id_noteId_userId` ON `${TABLE_NAME}` (`noteId`, `userId`)" + }, + { + "name": "index_pinned_note_id_userId", + "unique": false, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_pinned_note_id_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "user_instance_info", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`faviconUrl` TEXT, `iconUrl` TEXT, `name` TEXT, `softwareName` TEXT, `softwareVersion` TEXT, `themeColor` TEXT, `userId` INTEGER NOT NULL, PRIMARY KEY(`userId`), FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "faviconUrl", + "columnName": "faviconUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "iconUrl", + "columnName": "iconUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "softwareName", + "columnName": "softwareName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "softwareVersion", + "columnName": "softwareVersion", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "themeColor", + "columnName": "themeColor", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "userId" + ] + }, + "indices": [ + { + "name": "index_user_instance_info_userId", + "unique": false, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_instance_info_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "user_profile_field", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `value` TEXT NOT NULL, `userId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_user_profile_field_userId", + "unique": false, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_profile_field_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "word_filter_condition", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "word_filter_regex_condition", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`pattern` TEXT NOT NULL, `parentId` INTEGER NOT NULL, PRIMARY KEY(`parentId`), FOREIGN KEY(`parentId`) REFERENCES `word_filter_condition`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "pattern", + "columnName": "pattern", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "parentId", + "columnName": "parentId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "parentId" + ] + }, + "indices": [ + { + "name": "index_word_filter_regex_condition_parentId", + "unique": false, + "columnNames": [ + "parentId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_word_filter_regex_condition_parentId` ON `${TABLE_NAME}` (`parentId`)" + } + ], + "foreignKeys": [ + { + "table": "word_filter_condition", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "parentId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "word_filter_word_condition", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`word` TEXT NOT NULL, `parentId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`parentId`) REFERENCES `word_filter_condition`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "word", + "columnName": "word", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "parentId", + "columnName": "parentId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_word_filter_word_condition_parentId", + "unique": false, + "columnNames": [ + "parentId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_word_filter_word_condition_parentId` ON `${TABLE_NAME}` (`parentId`)" + } + ], + "foreignKeys": [ + { + "table": "word_filter_condition", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "parentId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "user_list", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `createdAt` TEXT NOT NULL, `name` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`accountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "serverId", + "columnName": "serverId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_user_list_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_list_accountId` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "index_user_list_serverId", + "unique": false, + "columnNames": [ + "serverId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_list_serverId` ON `${TABLE_NAME}` (`serverId`)" + }, + { + "name": "index_user_list_accountId_serverId", + "unique": true, + "columnNames": [ + "accountId", + "serverId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_list_accountId_serverId` ON `${TABLE_NAME}` (`accountId`, `serverId`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "user_list_member", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`userListId` INTEGER NOT NULL, `userId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`userListId`) REFERENCES `user_list`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "userListId", + "columnName": "userListId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_user_list_member_userListId", + "unique": false, + "columnNames": [ + "userListId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_list_member_userListId` ON `${TABLE_NAME}` (`userListId`)" + }, + { + "name": "index_user_list_member_userListId_userId", + "unique": true, + "columnNames": [ + "userListId", + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_list_member_userListId_userId` ON `${TABLE_NAME}` (`userListId`, `userId`)" + } + ], + "foreignKeys": [ + { + "table": "user_list", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userListId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "instance_info_v1_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `host` TEXT NOT NULL, `name` TEXT, `description` TEXT, `clientMaxBodyByteSize` INTEGER, `iconUrl` TEXT, `themeColor` TEXT, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "host", + "columnName": "host", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "clientMaxBodyByteSize", + "columnName": "clientMaxBodyByteSize", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "iconUrl", + "columnName": "iconUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "themeColor", + "columnName": "themeColor", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_instance_info_v1_table_host", + "unique": true, + "columnNames": [ + "host" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_instance_info_v1_table_host` ON `${TABLE_NAME}` (`host`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "user_badge_role", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `iconUrl` TEXT, `displayOrder` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "iconUrl", + "columnName": "iconUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "displayOrder", + "columnName": "displayOrder", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_user_badge_role_userId", + "unique": false, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_user_badge_role_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "search_histories", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `keyword` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`accountId`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "keyword", + "columnName": "keyword", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_search_histories_keyword_accountId", + "unique": true, + "columnNames": [ + "keyword", + "accountId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_search_histories_keyword_accountId` ON `${TABLE_NAME}` (`keyword`, `accountId`)" + }, + { + "name": "index_search_histories_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_search_histories_accountId` ON `${TABLE_NAME}` (`accountId`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "user_info_state", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`description` TEXT, `followersCount` INTEGER, `followingCount` INTEGER, `hostLower` TEXT, `notesCount` INTEGER, `bannerUrl` TEXT, `url` TEXT, `isLocked` INTEGER NOT NULL, `birthday` TEXT, `createdAt` TEXT, `updatedAt` TEXT, `publicReactions` INTEGER, `userId` INTEGER NOT NULL, `ffVisibility` TEXT, PRIMARY KEY(`userId`), FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "followersCount", + "columnName": "followersCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "followingCount", + "columnName": "followingCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "hostLower", + "columnName": "hostLower", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "notesCount", + "columnName": "notesCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bannerUrl", + "columnName": "bannerUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isLocked", + "columnName": "isLocked", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "birthday", + "columnName": "birthday", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "updatedAt", + "columnName": "updatedAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "publicReactions", + "columnName": "publicReactions", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "ffVisibility", + "columnName": "ffVisibility", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "userId" + ] + }, + "indices": [ + { + "name": "index_user_info_state_userId", + "unique": true, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_info_state_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "user_related_state", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`isFollowing` INTEGER NOT NULL, `isFollower` INTEGER NOT NULL, `isBlocking` INTEGER NOT NULL, `isMuting` INTEGER NOT NULL, `hasPendingFollowRequestFromYou` INTEGER NOT NULL, `hasPendingFollowRequestToYou` INTEGER NOT NULL, `isNotify` INTEGER, `userId` INTEGER NOT NULL, PRIMARY KEY(`userId`), FOREIGN KEY(`userId`) REFERENCES `user`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "isFollowing", + "columnName": "isFollowing", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isFollower", + "columnName": "isFollower", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isBlocking", + "columnName": "isBlocking", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isMuting", + "columnName": "isMuting", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasPendingFollowRequestFromYou", + "columnName": "hasPendingFollowRequestFromYou", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasPendingFollowRequestToYou", + "columnName": "hasPendingFollowRequestToYou", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isNotify", + "columnName": "isNotify", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "userId" + ] + }, + "indices": [ + { + "name": "index_user_related_state_userId", + "unique": true, + "columnNames": [ + "userId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_user_related_state_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "user", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "userId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "nodeinfo", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`host` TEXT NOT NULL, `nodeInfoVersion` TEXT NOT NULL, `name` TEXT NOT NULL, `version` TEXT NOT NULL, PRIMARY KEY(`host`))", + "fields": [ + { + "fieldPath": "host", + "columnName": "host", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "nodeInfoVersion", + "columnName": "nodeInfoVersion", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "host" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "mastodon_instance_info", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uri` TEXT NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `email` TEXT NOT NULL, `version` TEXT NOT NULL, `urls_streamingApi` TEXT, `configuration_statuses_maxCharacters` INTEGER, `configuration_statuses_maxMediaAttachments` INTEGER, `configuration_polls_maxOptions` INTEGER, `configuration_polls_maxCharactersPerOption` INTEGER, `configuration_polls_minExpiration` INTEGER, `configuration_polls_maxExpiration` INTEGER, `configuration_emoji_reactions_myReactions` INTEGER, `configuration_emoji_reactions_maxReactionsPerAccount` INTEGER, PRIMARY KEY(`uri`))", + "fields": [ + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "email", + "columnName": "email", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "urls.streamingApi", + "columnName": "urls_streamingApi", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "configuration.statuses.maxCharacters", + "columnName": "configuration_statuses_maxCharacters", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.statuses.maxMediaAttachments", + "columnName": "configuration_statuses_maxMediaAttachments", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.polls.maxOptions", + "columnName": "configuration_polls_maxOptions", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.polls.maxCharactersPerOption", + "columnName": "configuration_polls_maxCharactersPerOption", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.polls.minExpiration", + "columnName": "configuration_polls_minExpiration", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.polls.maxExpiration", + "columnName": "configuration_polls_maxExpiration", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.emojiReactions.maxReactions", + "columnName": "configuration_emoji_reactions_myReactions", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "configuration.emojiReactions.maxReactionsPerAccount", + "columnName": "configuration_emoji_reactions_maxReactionsPerAccount", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "uri" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notification_json_cache_v1", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `notificationId` TEXT NOT NULL, `json` TEXT NOT NULL, `key` TEXT, `weight` INTEGER NOT NULL, PRIMARY KEY(`accountId`, `notificationId`))", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "notificationId", + "columnName": "notificationId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "json", + "columnName": "json", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "weight", + "columnName": "weight", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountId", + "notificationId" + ] + }, + "indices": [ + { + "name": "index_notification_json_cache_v1_key", + "unique": false, + "columnNames": [ + "key" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notification_json_cache_v1_key` ON `${TABLE_NAME}` (`key`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "mastodon_word_filters_v1", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `filterId` TEXT NOT NULL, `phrase` TEXT NOT NULL, `wholeWord` INTEGER NOT NULL, `expiresAt` TEXT, `irreversible` INTEGER NOT NULL, `isContextHome` INTEGER NOT NULL, `isContextNotifications` INTEGER NOT NULL, `isContextPublic` INTEGER NOT NULL, `isContextThread` INTEGER NOT NULL, `isContextAccount` INTEGER NOT NULL, PRIMARY KEY(`accountId`, `filterId`))", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "filterId", + "columnName": "filterId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "phrase", + "columnName": "phrase", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "wholeWord", + "columnName": "wholeWord", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "expiresAt", + "columnName": "expiresAt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "irreversible", + "columnName": "irreversible", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isContextHome", + "columnName": "isContextHome", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isContextNotifications", + "columnName": "isContextNotifications", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isContextPublic", + "columnName": "isContextPublic", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isContextThread", + "columnName": "isContextThread", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isContextAccount", + "columnName": "isContextAccount", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountId", + "filterId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "renote_mute_users", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `userId` TEXT NOT NULL, `createdAt` TEXT NOT NULL, `postedAt` TEXT, PRIMARY KEY(`userId`, `accountId`))", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "createdAt", + "columnName": "createdAt", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "postedAt", + "columnName": "postedAt", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "userId", + "accountId" + ] + }, + "indices": [ + { + "name": "index_renote_mute_users_postedAt", + "unique": false, + "columnNames": [ + "postedAt" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_renote_mute_users_postedAt` ON `${TABLE_NAME}` (`postedAt`)" + }, + { + "name": "index_renote_mute_users_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_renote_mute_users_accountId` ON `${TABLE_NAME}` (`accountId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "mastodon_instance_fedibird_capabilities", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`type` TEXT NOT NULL, `uri` TEXT NOT NULL, PRIMARY KEY(`uri`, `type`), FOREIGN KEY(`uri`) REFERENCES `mastodon_instance_info`(`uri`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "uri", + "type" + ] + }, + "indices": [ + { + "name": "index_mastodon_instance_fedibird_capabilities_uri", + "unique": false, + "columnNames": [ + "uri" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mastodon_instance_fedibird_capabilities_uri` ON `${TABLE_NAME}` (`uri`)" + } + ], + "foreignKeys": [ + { + "table": "mastodon_instance_info", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "uri" + ], + "referencedColumns": [ + "uri" + ] + } + ] + }, + { + "tableName": "pleroma_metadata_features", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`type` TEXT NOT NULL, `uri` TEXT NOT NULL, PRIMARY KEY(`uri`, `type`), FOREIGN KEY(`uri`) REFERENCES `mastodon_instance_info`(`uri`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "uri", + "type" + ] + }, + "indices": [ + { + "name": "index_pleroma_metadata_features_uri", + "unique": false, + "columnNames": [ + "uri" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_pleroma_metadata_features_uri` ON `${TABLE_NAME}` (`uri`)" + } + ], + "foreignKeys": [ + { + "table": "mastodon_instance_info", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "uri" + ], + "referencedColumns": [ + "uri" + ] + } + ] + }, + { + "tableName": "custom_emojis", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `emojiHost` TEXT NOT NULL, `url` TEXT, `uri` TEXT, `type` TEXT, `serverId` TEXT, `category` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "emojiHost", + "columnName": "emojiHost", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "serverId", + "columnName": "serverId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_custom_emojis_emojiHost_name", + "unique": false, + "columnNames": [ + "emojiHost", + "name" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_custom_emojis_emojiHost_name` ON `${TABLE_NAME}` (`emojiHost`, `name`)" + }, + { + "name": "index_custom_emojis_emojiHost", + "unique": false, + "columnNames": [ + "emojiHost" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_custom_emojis_emojiHost` ON `${TABLE_NAME}` (`emojiHost`)" + }, + { + "name": "index_custom_emojis_name", + "unique": false, + "columnNames": [ + "name" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_custom_emojis_name` ON `${TABLE_NAME}` (`name`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "custom_emoji_aliases", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `emojiId` INTEGER NOT NULL, PRIMARY KEY(`name`, `emojiId`), FOREIGN KEY(`emojiId`) REFERENCES `custom_emojis`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "emojiId", + "columnName": "emojiId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "name", + "emojiId" + ] + }, + "indices": [ + { + "name": "index_custom_emoji_aliases_emojiId", + "unique": false, + "columnNames": [ + "emojiId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_custom_emoji_aliases_emojiId` ON `${TABLE_NAME}` (`emojiId`)" + }, + { + "name": "index_custom_emoji_aliases_name", + "unique": false, + "columnNames": [ + "name" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_custom_emoji_aliases_name` ON `${TABLE_NAME}` (`name`)" + } + ], + "foreignKeys": [ + { + "table": "custom_emojis", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "emojiId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "instance_tickers", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uri` TEXT NOT NULL, `favicon_url` TEXT, `icon_url` TEXT, `name` TEXT, `software_name` TEXT, `software_version` TEXT, `theme_color` TEXT, `created_at` TEXT NOT NULL, PRIMARY KEY(`uri`))", + "fields": [ + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "faviconUrl", + "columnName": "favicon_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "iconUrl", + "columnName": "icon_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "softwareName", + "columnName": "software_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "softwareVersion", + "columnName": "software_version", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "themeColor", + "columnName": "theme_color", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "cachedAt", + "columnName": "created_at", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "uri" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `account_id` INTEGER NOT NULL, `note_id` TEXT NOT NULL, `created_at` TEXT NOT NULL, `text` TEXT, `cw` TEXT, `user_id` TEXT NOT NULL, `reply_id` TEXT, `repost_id` TEXT, `via_mobile` INTEGER, `visibility` TEXT NOT NULL, `local_only` INTEGER, `url` TEXT, `uri` TEXT, `repost_count` INTEGER NOT NULL, `reply_count` INTEGER NOT NULL, `channel_id` TEXT, `max_reaction_per_account` INTEGER NOT NULL, `polls_expires_at` TEXT, `polls_multiple` INTEGER, `circle_id` TEXT, `type` TEXT NOT NULL, `mastodon_reblogged` INTEGER, `mastodon_favourited` INTEGER, `mastodon_bookmarked` INTEGER, `mastodon_muted` INTEGER, `mastodon_favourites_count` INTEGER, `mastodon_is_fedibird_quote` INTEGER, `mastodon_poll_id` TEXT, `mastodon_is_sensitive` INTEGER, `mastodon_pure_text` TEXT, `mastodon_is_reaction_available` INTEGER, `misskey_channel_id` TEXT, `misskey_channel_name` TEXT, `misskey_is_accepting_only_like_reaction` INTEGER, `misskey_is_not_accepting_sensitive_reaction` INTEGER, `misskey_is_require_nyaize` INTEGER, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "account_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "createdAt", + "columnName": "created_at", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "cw", + "columnName": "cw", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "replyId", + "columnName": "reply_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "repostId", + "columnName": "repost_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "viaMobile", + "columnName": "via_mobile", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "visibility", + "columnName": "visibility", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "localOnly", + "columnName": "local_only", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "repostCount", + "columnName": "repost_count", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "replyCount", + "columnName": "reply_count", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "channelId", + "columnName": "channel_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "maxReactionPerAccount", + "columnName": "max_reaction_per_account", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "pollExpiresAt", + "columnName": "polls_expires_at", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pollMultiple", + "columnName": "polls_multiple", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "fedibirdCircleId", + "columnName": "circle_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "mastodonReblogged", + "columnName": "mastodon_reblogged", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonFavourited", + "columnName": "mastodon_favourited", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonBookmarked", + "columnName": "mastodon_bookmarked", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonMuted", + "columnName": "mastodon_muted", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonFavouritesCount", + "columnName": "mastodon_favourites_count", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonIsFedibirdQuote", + "columnName": "mastodon_is_fedibird_quote", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonPollId", + "columnName": "mastodon_poll_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "mastodonIsSensitive", + "columnName": "mastodon_is_sensitive", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "mastodonPureText", + "columnName": "mastodon_pure_text", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "mastodonIsReactionAvailable", + "columnName": "mastodon_is_reaction_available", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "misskeyChannelId", + "columnName": "misskey_channel_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "misskeyChannelName", + "columnName": "misskey_channel_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "misskeyIsAcceptingOnlyLikeReaction", + "columnName": "misskey_is_accepting_only_like_reaction", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "misskeyIsNotAcceptingSensitiveReaction", + "columnName": "misskey_is_not_accepting_sensitive_reaction", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "misskeyIsRequireNyaize", + "columnName": "misskey_is_require_nyaize", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "reaction_counts", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `note_id` TEXT NOT NULL, `reaction` TEXT NOT NULL, `count` INTEGER NOT NULL, `me` INTEGER NOT NULL, `weight` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "reaction", + "columnName": "reaction", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "count", + "columnName": "count", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "me", + "columnName": "me", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "weight", + "columnName": "weight", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_reaction_counts_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_reaction_counts_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "note_visible_user_ids", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`note_id` TEXT NOT NULL, `user_id` TEXT NOT NULL, PRIMARY KEY(`note_id`, `user_id`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "note_id", + "user_id" + ] + }, + "indices": [ + { + "name": "index_note_visible_user_ids_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_note_visible_user_ids_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "note_poll_choices", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `note_id` TEXT NOT NULL, `index` INTEGER NOT NULL, `text` TEXT NOT NULL, `votes` INTEGER NOT NULL, `is_voted` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "index", + "columnName": "index", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "votes", + "columnName": "votes", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isVoted", + "columnName": "is_voted", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_note_poll_choices_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_note_poll_choices_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "mastodon_tags", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`note_id` TEXT NOT NULL, `tag` TEXT NOT NULL, `url` TEXT NOT NULL, PRIMARY KEY(`note_id`, `tag`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "tag", + "columnName": "tag", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "note_id", + "tag" + ] + }, + "indices": [ + { + "name": "index_mastodon_tags_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mastodon_tags_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "mastodon_mentions", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`note_id` TEXT NOT NULL, `user_id` TEXT NOT NULL, `username` TEXT NOT NULL, `acct` TEXT NOT NULL, `url` TEXT NOT NULL, PRIMARY KEY(`note_id`, `user_id`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "username", + "columnName": "username", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "acct", + "columnName": "acct", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "note_id", + "user_id" + ] + }, + "indices": [ + { + "name": "index_mastodon_mentions_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mastodon_mentions_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "note_custom_emojis", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `note_id` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT, `aspect_ratio` REAL, `cache_path` TEXT, PRIMARY KEY(`id`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "aspectRatio", + "columnName": "aspect_ratio", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "cachePath", + "columnName": "cache_path", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_note_custom_emojis_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_note_custom_emojis_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "note_files", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`note_id` TEXT NOT NULL, `file_id` TEXT NOT NULL, PRIMARY KEY(`note_id`, `file_id`), FOREIGN KEY(`note_id`) REFERENCES `notes`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "fileId", + "columnName": "file_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "note_id", + "file_id" + ] + }, + "indices": [ + { + "name": "index_note_files_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_note_files_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "note_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "note_threads", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `targetNoteId` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "targetNoteId", + "columnName": "targetNoteId", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "note_thread_ancestors", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`thread_id` TEXT NOT NULL, `note_id` TEXT NOT NULL, PRIMARY KEY(`thread_id`, `note_id`))", + "fields": [ + { + "fieldPath": "threadId", + "columnName": "thread_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "thread_id", + "note_id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "note_thread_descendants", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`thread_id` TEXT NOT NULL, `note_id` TEXT NOT NULL, PRIMARY KEY(`thread_id`, `note_id`))", + "fields": [ + { + "fieldPath": "threadId", + "columnName": "thread_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "thread_id", + "note_id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "timeline_item", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`account_id` INTEGER NOT NULL, `page_id` INTEGER NOT NULL, `note_id` TEXT NOT NULL, `note_local_id` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`note_local_id`) REFERENCES `notes`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "account_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "pageId", + "columnName": "page_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteLocalId", + "columnName": "note_local_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_timeline_item_account_id_page_id_note_id", + "unique": true, + "columnNames": [ + "account_id", + "page_id", + "note_id" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_timeline_item_account_id_page_id_note_id` ON `${TABLE_NAME}` (`account_id`, `page_id`, `note_id`)" + }, + { + "name": "index_timeline_item_note_id", + "unique": false, + "columnNames": [ + "note_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_timeline_item_note_id` ON `${TABLE_NAME}` (`note_id`)" + } + ], + "foreignKeys": [ + { + "table": "notes", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "note_local_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `notification_id` TEXT NOT NULL, `account_id` INTEGER NOT NULL, `created_at` TEXT NOT NULL, `type` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`account_id`) REFERENCES `account_table`(`accountId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "notificationId", + "columnName": "notification_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "account_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "createdAt", + "columnName": "created_at", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_notifications_account_id", + "unique": false, + "columnNames": [ + "account_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notifications_account_id` ON `${TABLE_NAME}` (`account_id`)" + } + ], + "foreignKeys": [ + { + "table": "account_table", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "account_id" + ], + "referencedColumns": [ + "accountId" + ] + } + ] + }, + { + "tableName": "follow_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `user_id` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "note_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `note_id` TEXT NOT NULL, `user_id` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "reaction_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `reaction` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "reaction", + "columnName": "reaction", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "poll_vote_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `choice` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "choice", + "columnName": "choice", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "group_invited_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `group_id` TEXT NOT NULL, `group_name` TEXT NOT NULL, `group_owner_id` TEXT NOT NULL, `group_created_at` TEXT NOT NULL, `invitation_id` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "groupId", + "columnName": "group_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "groupName", + "columnName": "group_name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "groupOwnerId", + "columnName": "group_owner_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "groupCreatedAt", + "columnName": "group_created_at", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "invitationId", + "columnName": "invitation_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "unknown_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `raw_type` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "rawType", + "columnName": "raw_type", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "poll_ended_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `note_id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notification_timelines", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notification_timeline_excluded_types", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timelineId` INTEGER NOT NULL, `type` TEXT NOT NULL, PRIMARY KEY(`timelineId`, `type`))", + "fields": [ + { + "fieldPath": "timelineId", + "columnName": "timelineId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "timelineId", + "type" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notification_timeline_included_types", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timelineId` INTEGER NOT NULL, `type` TEXT NOT NULL, PRIMARY KEY(`timelineId`, `type`))", + "fields": [ + { + "fieldPath": "timelineId", + "columnName": "timelineId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "timelineId", + "type" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notification_timeline_items", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timelineId` INTEGER NOT NULL, `notificationId` TEXT NOT NULL, `cachedAt` INTEGER NOT NULL, PRIMARY KEY(`timelineId`, `notificationId`))", + "fields": [ + { + "fieldPath": "timelineId", + "columnName": "timelineId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "notificationId", + "columnName": "notificationId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "cachedAt", + "columnName": "cachedAt", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "timelineId", + "notificationId" + ] + }, + "indices": [ + { + "name": "index_notification_timeline_items_timelineId", + "unique": false, + "columnNames": [ + "timelineId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notification_timeline_items_timelineId` ON `${TABLE_NAME}` (`timelineId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "follow_request_accepted_notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `user_id` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `notifications`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [ + { + "table": "notifications", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "reaction_authors", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `account_id` INTEGER NOT NULL, `reaction` TEXT, `note_id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "account_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "reaction", + "columnName": "reaction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "noteId", + "columnName": "note_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "reaction_authors_users", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`reaction_author_id` TEXT NOT NULL, `user_id` TEXT NOT NULL, PRIMARY KEY(`reaction_author_id`, `user_id`), FOREIGN KEY(`reaction_author_id`) REFERENCES `reaction_authors`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "reactionAuthorId", + "columnName": "reaction_author_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "reaction_author_id", + "user_id" + ] + }, + "indices": [ + { + "name": "index_reaction_authors_users_reaction_author_id_user_id", + "unique": false, + "columnNames": [ + "reaction_author_id", + "user_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_reaction_authors_users_reaction_author_id_user_id` ON `${TABLE_NAME}` (`reaction_author_id`, `user_id`)" + }, + { + "name": "index_reaction_authors_users_reaction_author_id", + "unique": false, + "columnNames": [ + "reaction_author_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_reaction_authors_users_reaction_author_id` ON `${TABLE_NAME}` (`reaction_author_id`)" + } + ], + "foreignKeys": [ + { + "table": "reaction_authors", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "reaction_author_id" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "custom_emoji_aspects", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uri` TEXT NOT NULL, `aspect_ratio` REAL NOT NULL, PRIMARY KEY(`uri`))", + "fields": [ + { + "fieldPath": "uri", + "columnName": "uri", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "aspectRatio", + "columnName": "aspect_ratio", + "affinity": "REAL", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "uri" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "image_caches", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`source_url` TEXT NOT NULL, `cache_path` TEXT NOT NULL, `cached_at` INTEGER NOT NULL, `width` INTEGER, `height` INTEGER, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", + "fields": [ + { + "fieldPath": "sourceUrl", + "columnName": "source_url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "cachePath", + "columnName": "cache_path", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "cachedAt", + "columnName": "cached_at", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "width", + "columnName": "width", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "height", + "columnName": "height", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_image_caches_source_url", + "unique": true, + "columnNames": [ + "source_url" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_image_caches_source_url` ON `${TABLE_NAME}` (`source_url`)" + }, + { + "name": "index_image_caches_cached_at", + "unique": false, + "columnNames": [ + "cached_at" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_image_caches_cached_at` ON `${TABLE_NAME}` (`cached_at`)" + } + ], + "foreignKeys": [] + } + ], + "views": [ + { + "viewName": "user_view", + "createSql": "CREATE VIEW `${VIEW_NAME}` AS select user.*, nicknames.nickname from user left join nicknames on user.userName = nicknames.username and user.host = nicknames.host" + }, + { + "viewName": "group_member_view", + "createSql": "CREATE VIEW `${VIEW_NAME}` AS select m.groupId, u.id as userId, u.avatarUrl, u.serverId from group_member_v1 as m \n inner join group_v1 as g\n inner join user as u\n on m.groupId = g.id\n and m.userId = u.serverId\n and g.accountId = u.accountId" + }, + { + "viewName": "user_list_member_view", + "createSql": "CREATE VIEW `${VIEW_NAME}` AS select m.userListId, u.id as userId, u.avatarUrl, u.serverId from user_list_member as m \n inner join user_list as ul\n inner join user as u\n on m.userListId = ul.id\n and m.userId = u.serverId\n and ul.accountId = u.accountId" + } + ], + "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, '88a9400e4ded90d995fe9d03585f39bc')" + ] + } +} \ No newline at end of file diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/di/module/DbModule.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/di/module/DbModule.kt index edc7b7cd1d..587e569b75 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/di/module/DbModule.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/di/module/DbModule.kt @@ -173,4 +173,8 @@ object DbModule { @Provides @Singleton fun provideCustomEmojiAspectDAO(db: DataBase) = db.customEmojiAspectDAO() + + @Provides + @Singleton + fun provideImageCacheDAO(db: DataBase) = db.imageCacheDAO() } \ No newline at end of file diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/DataBase.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/DataBase.kt index 87de86ecf5..b4a7995c71 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/DataBase.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/DataBase.kt @@ -23,6 +23,8 @@ import net.pantasystem.milktea.data.infrastructure.group.GroupDao import net.pantasystem.milktea.data.infrastructure.group.GroupMemberIdRecord import net.pantasystem.milktea.data.infrastructure.group.GroupMemberView import net.pantasystem.milktea.data.infrastructure.group.GroupRecord +import net.pantasystem.milktea.data.infrastructure.image.ImageCacheDAO +import net.pantasystem.milktea.data.infrastructure.image.ImageCacheEntity import net.pantasystem.milktea.data.infrastructure.instance.db.FedibirdCapabilitiesRecord import net.pantasystem.milktea.data.infrastructure.instance.db.InstanceInfoDao import net.pantasystem.milktea.data.infrastructure.instance.db.InstanceInfoRecord @@ -210,8 +212,10 @@ import net.pantasystem.milktea.data.infrastructure.user.renote.mute.db.RenoteMut ReactionUserEntity::class, CustomEmojiAspectRatioEntity::class, + + ImageCacheEntity::class, ], - version = 72, + version = 73, exportSchema = true, autoMigrations = [ AutoMigration(from = 11, to = 12), @@ -273,6 +277,7 @@ import net.pantasystem.milktea.data.infrastructure.user.renote.mute.db.RenoteMut AutoMigration(from = 69, to = 70), AutoMigration(from = 70, to = 71), AutoMigration(from = 71, to = 72), + AutoMigration(from = 72, to = 73) ], views = [UserView::class, GroupMemberView::class, UserListMemberView::class] ) @@ -347,4 +352,6 @@ abstract class DataBase : RoomDatabase() { abstract fun reactionAuthorDAO(): ReactionAuthorDAO abstract fun customEmojiAspectDAO(): CustomEmojiAspectRatioDAO + + abstract fun imageCacheDAO(): ImageCacheDAO } \ No newline at end of file diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheDAO.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheDAO.kt new file mode 100644 index 0000000000..e81edf6ab8 --- /dev/null +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheDAO.kt @@ -0,0 +1,52 @@ +package net.pantasystem.milktea.data.infrastructure.image + +import androidx.room.Dao +import androidx.room.Query +import androidx.room.Upsert + +@Dao +interface ImageCacheDAO { + + @Query( + """ + SELECT * FROM image_caches WHERE source_url = :url AND cached_at > :newerThan + """ + ) + suspend fun findBySourceUrl(url: String, newerThan: Long): ImageCacheEntity? + + @Query( + """ + SELECT * FROM image_caches WHERE cached_at < :olderThan + """ + ) + suspend fun findOlder(olderThan: Long): List + + @Query( + """ + DELETE FROM image_caches; + """ + ) + suspend fun clear() + + @Query( + """ + SELECT * FROM image_caches WHERE source_url in (:urls) + AND cached_at > :newerThan + """ + ) + suspend fun findBySourceUrls(urls: List, newerThan: Long): List + + @Upsert + suspend fun upsert(entity: ImageCacheEntity): Long + + + @Query( + """ + SELECT count(*) FROM image_caches + """ + ) + suspend fun count(): Long + + @Query("""DELETE FROM image_caches WHERE source_url = :url""") + suspend fun deleteByUrl(url: String) +} \ No newline at end of file diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheEntity.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheEntity.kt new file mode 100644 index 0000000000..5581d181cd --- /dev/null +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheEntity.kt @@ -0,0 +1,52 @@ +package net.pantasystem.milktea.data.infrastructure.image + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.Index +import androidx.room.PrimaryKey +import kotlinx.datetime.Instant +import net.pantasystem.milktea.model.image.ImageCache + +@Entity( + tableName = "image_caches", + indices = [ + Index( + "source_url", + unique = true, + ), + Index( + "cached_at" + ) + ] +) +data class ImageCacheEntity( + @ColumnInfo("source_url") val sourceUrl: String, + @ColumnInfo("cache_path") val cachePath: String, + @ColumnInfo("cached_at") val cachedAt: Long, + @ColumnInfo("width") val width: Int?, + @ColumnInfo("height") val height: Int?, + @ColumnInfo("id") @PrimaryKey(autoGenerate = true) val id: Long = 0L, +) { + + companion object { + fun from(model: ImageCache): ImageCacheEntity { + return ImageCacheEntity( + sourceUrl = model.sourceUrl, + cachePath = model.cachePath, + cachedAt = model.cachedAt.toEpochMilliseconds(), + width = model.width, + height = model.height, + ) + } + } + + fun toModel(): ImageCache { + return ImageCache( + sourceUrl = sourceUrl, + cachePath = cachePath, + cachedAt = Instant.fromEpochMilliseconds(cachedAt), + width = width, + height = height, + ) + } +} \ No newline at end of file diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt index 43b07aacd4..2c785c061a 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt @@ -3,9 +3,6 @@ package net.pantasystem.milktea.data.infrastructure.image import android.content.Context import android.graphics.BitmapFactory import dagger.hilt.android.qualifiers.ApplicationContext -import io.objectbox.kotlin.awaitCallInTx -import io.objectbox.kotlin.inValues -import io.objectbox.query.QueryBuilder import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.withContext import kotlinx.datetime.Clock @@ -13,7 +10,6 @@ import net.pantasystem.milktea.api.misskey.OkHttpClientProvider import net.pantasystem.milktea.common.Hash import net.pantasystem.milktea.common.runCancellableCatching import net.pantasystem.milktea.common_android.hilt.IODispatcher -import net.pantasystem.milktea.data.infrastructure.BoxStoreHolder import net.pantasystem.milktea.model.image.ImageCache import net.pantasystem.milktea.model.image.ImageCacheRepository import okhttp3.Request @@ -23,10 +19,10 @@ import kotlin.time.Duration.Companion.days class ImageCacheRepositoryImpl @Inject constructor( - private val boxStoreHolder: BoxStoreHolder, private val okHttpClientProvider: OkHttpClientProvider, @ApplicationContext val context: Context, @IODispatcher val coroutineDispatcher: CoroutineDispatcher, + private val imageCacheDAO: ImageCacheDAO, ) : ImageCacheRepository { companion object { @@ -35,10 +31,6 @@ class ImageCacheRepositoryImpl @Inject constructor( val cacheIgnoreUpdateDuration = 3.days } - private val imageCacheStore by lazy { - boxStoreHolder.boxStore.boxFor(ImageCacheRecord::class.java) - } - override suspend fun save(url: String) = runCancellableCatching { when (val cache = findBySourceUrl(url).getOrThrow()) { null -> Unit @@ -73,17 +65,8 @@ class ImageCacheRepositoryImpl @Inject constructor( override suspend fun findBySourceUrl(url: String): Result = runCancellableCatching { withContext(coroutineDispatcher) { val now = Clock.System.now() - val record = imageCacheStore.query().equal( - ImageCacheRecord_.sourceUrl, - url, - QueryBuilder.StringOrder.CASE_SENSITIVE - ).build().findFirst() - val model = record?.toModel() - if (model != null && now - model.cachedAt > cacheExpireDuration) { - imageCacheStore.remove(record) - null - } else { - model + imageCacheDAO.findBySourceUrl(url, (now - cacheExpireDuration).toEpochMilliseconds())?.let { + it.toModel() } } } @@ -91,29 +74,21 @@ class ImageCacheRepositoryImpl @Inject constructor( override suspend fun deleteExpiredCaches(): Result = runCancellableCatching { withContext(coroutineDispatcher) { val now = Clock.System.now() - val query = imageCacheStore.query().lessOrEqual( - ImageCacheRecord_.cachedAt, - (now - cacheExpireDuration).toEpochMilliseconds() - ).build() - - val deleteCacheSize = query.count() - for (i in 0 until deleteCacheSize step 100) { - val list = query.find(i, 100) - list.forEach { - val file = File(it.cachePath) - if (file.exists()) { - file.delete() - } + val targets = imageCacheDAO.findOlder((now - cacheExpireDuration).toEpochMilliseconds()) + targets.forEach { + imageCacheDAO.deleteByUrl(it.sourceUrl) + val file = File(it.cachePath) + if (file.exists()) { + file.delete() } - imageCacheStore.remove(list) + imageCacheDAO.deleteByUrl(it.sourceUrl) } - } } override suspend fun clear(): Result = runCancellableCatching { withContext(coroutineDispatcher) { - imageCacheStore.removeAll() + imageCacheDAO.clear() File(context.filesDir, cacheDir).deleteRecursively() } } @@ -121,41 +96,17 @@ class ImageCacheRepositoryImpl @Inject constructor( override suspend fun findBySourceUrls(urls: List): Result> = runCancellableCatching { withContext(coroutineDispatcher) { val now = Clock.System.now() - urls.chunked(50) { list -> - val records = imageCacheStore.query().inValues( - ImageCacheRecord_.sourceUrl, - list.toTypedArray(), - QueryBuilder.StringOrder.CASE_SENSITIVE - ).build().find() - records.mapNotNull { record -> - val model = record.toModel() - if (now - model.cachedAt > cacheExpireDuration) { - null - } else { - model - } - } + urls.chunked(300).map { list -> + imageCacheDAO.findBySourceUrls( + list, + (now - cacheExpireDuration).toEpochMilliseconds(), + ) } - }.flatten() + }.flatten().map { it.toModel() } } private suspend fun upInsert(cache: ImageCache) { - val record = ImageCacheRecord.from( - cache - ) - boxStoreHolder.boxStore.awaitCallInTx { - val existsRecord = imageCacheStore.query().equal( - ImageCacheRecord_.sourceUrl, - cache.sourceUrl, - QueryBuilder.StringOrder.CASE_SENSITIVE - ).build().findFirst() - if (existsRecord == null) { - imageCacheStore.put(record) - } else { - existsRecord.applyModel(record.toModel()) - imageCacheStore.put(existsRecord) - } - } + imageCacheDAO.upsert(ImageCacheEntity.from(cache)) } private fun downloadAndSaveFile(url: String, file: File): Pair { @@ -188,7 +139,7 @@ class ImageCacheRepositoryImpl @Inject constructor( } dir.listFiles()?.size?.toLong() ?: 0L } else { - imageCacheStore.count() + imageCacheDAO.count() } } } \ No newline at end of file