mirror of https://github.com/readrops/Readrops.git
Use setAllItemsRead insert methods for remote accounts
This commit is contained in:
parent
b9aa09e103
commit
4382bbb061
|
@ -0,0 +1,553 @@
|
||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 4,
|
||||||
|
"identityHash": "5043c0aff2ed15f8cbe250e35bb9129e",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "Feed",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `description` TEXT, `url` TEXT, `siteUrl` TEXT, `lastUpdated` TEXT, `text_color` INTEGER NOT NULL, `background_color` INTEGER NOT NULL, `icon_url` TEXT, `etag` TEXT, `last_modified` TEXT, `folder_id` INTEGER, `remoteId` TEXT, `account_id` INTEGER NOT NULL, `notification_enabled` INTEGER NOT NULL DEFAULT 1, FOREIGN KEY(`folder_id`) REFERENCES `Folder`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL , FOREIGN KEY(`account_id`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "url",
|
||||||
|
"columnName": "url",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "siteUrl",
|
||||||
|
"columnName": "siteUrl",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lastUpdated",
|
||||||
|
"columnName": "lastUpdated",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "textColor",
|
||||||
|
"columnName": "text_color",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "backgroundColor",
|
||||||
|
"columnName": "background_color",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "iconUrl",
|
||||||
|
"columnName": "icon_url",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "etag",
|
||||||
|
"columnName": "etag",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lastModified",
|
||||||
|
"columnName": "last_modified",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "folderId",
|
||||||
|
"columnName": "folder_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "remoteId",
|
||||||
|
"columnName": "remoteId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "accountId",
|
||||||
|
"columnName": "account_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "isNotificationEnabled",
|
||||||
|
"columnName": "notification_enabled",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_Feed_folder_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"folder_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_Feed_folder_id` ON `${TABLE_NAME}` (`folder_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_Feed_account_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_Feed_account_id` ON `${TABLE_NAME}` (`account_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "Folder",
|
||||||
|
"onDelete": "SET NULL",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"folder_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"table": "Account",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "Item",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `description` TEXT, `clean_description` TEXT, `link` TEXT, `image_link` TEXT, `author` TEXT, `pub_date` INTEGER, `content` TEXT, `feed_id` INTEGER NOT NULL, `guid` TEXT, `read_time` REAL NOT NULL, `read` INTEGER NOT NULL, `starred` INTEGER NOT NULL, `read_it_later` INTEGER NOT NULL, `remoteId` TEXT, FOREIGN KEY(`feed_id`) REFERENCES `Feed`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "title",
|
||||||
|
"columnName": "title",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "cleanDescription",
|
||||||
|
"columnName": "clean_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "link",
|
||||||
|
"columnName": "link",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "imageLink",
|
||||||
|
"columnName": "image_link",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "author",
|
||||||
|
"columnName": "author",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "pubDate",
|
||||||
|
"columnName": "pub_date",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "content",
|
||||||
|
"columnName": "content",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "feedId",
|
||||||
|
"columnName": "feed_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "guid",
|
||||||
|
"columnName": "guid",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "readTime",
|
||||||
|
"columnName": "read_time",
|
||||||
|
"affinity": "REAL",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "isRead",
|
||||||
|
"columnName": "read",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "isStarred",
|
||||||
|
"columnName": "starred",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "isReadItLater",
|
||||||
|
"columnName": "read_it_later",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "remoteId",
|
||||||
|
"columnName": "remoteId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_Item_feed_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"feed_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_Item_feed_id` ON `${TABLE_NAME}` (`feed_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_Item_guid",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"guid"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_Item_guid` ON `${TABLE_NAME}` (`guid`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "Feed",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"feed_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "Folder",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `remoteId` TEXT, `account_id` INTEGER NOT NULL, FOREIGN KEY(`account_id`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "remoteId",
|
||||||
|
"columnName": "remoteId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "accountId",
|
||||||
|
"columnName": "account_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_Folder_account_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_Folder_account_id` ON `${TABLE_NAME}` (`account_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "Account",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "Account",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT, `account_name` TEXT, `displayed_name` TEXT, `account_type` INTEGER, `last_modified` INTEGER NOT NULL, `current_account` INTEGER NOT NULL, `token` TEXT, `writeToken` TEXT, `notifications_enabled` INTEGER NOT NULL)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "url",
|
||||||
|
"columnName": "url",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "accountName",
|
||||||
|
"columnName": "account_name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "displayedName",
|
||||||
|
"columnName": "displayed_name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "accountType",
|
||||||
|
"columnName": "account_type",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lastModified",
|
||||||
|
"columnName": "last_modified",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "isCurrentAccount",
|
||||||
|
"columnName": "current_account",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "token",
|
||||||
|
"columnName": "token",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "writeToken",
|
||||||
|
"columnName": "writeToken",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "isNotificationsEnabled",
|
||||||
|
"columnName": "notifications_enabled",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "ItemStateChange",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `read_change` INTEGER NOT NULL, `star_change` INTEGER NOT NULL, `account_id` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`account_id`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "readChange",
|
||||||
|
"columnName": "read_change",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "starChange",
|
||||||
|
"columnName": "star_change",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "accountId",
|
||||||
|
"columnName": "account_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "Account",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "ItemState",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `read` INTEGER NOT NULL, `starred` INTEGER NOT NULL, `remote_id` TEXT NOT NULL, `account_id` INTEGER NOT NULL, FOREIGN KEY(`account_id`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "read",
|
||||||
|
"columnName": "read",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "starred",
|
||||||
|
"columnName": "starred",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "remoteId",
|
||||||
|
"columnName": "remote_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "accountId",
|
||||||
|
"columnName": "account_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_ItemState_remote_id_account_id",
|
||||||
|
"unique": true,
|
||||||
|
"columnNames": [
|
||||||
|
"remote_id",
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_ItemState_remote_id_account_id` ON `${TABLE_NAME}` (`remote_id`, `account_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "Account",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"account_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"views": [],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5043c0aff2ed15f8cbe250e35bb9129e')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.readrops.db
|
package com.readrops.db
|
||||||
|
|
||||||
|
import androidx.room.AutoMigration
|
||||||
import androidx.room.Database
|
import androidx.room.Database
|
||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import androidx.room.TypeConverters
|
import androidx.room.TypeConverters
|
||||||
|
@ -24,8 +25,13 @@ import com.readrops.db.entities.ItemState
|
||||||
import com.readrops.db.entities.ItemStateChange
|
import com.readrops.db.entities.ItemStateChange
|
||||||
import com.readrops.db.entities.account.Account
|
import com.readrops.db.entities.account.Account
|
||||||
|
|
||||||
@Database(entities = [Feed::class, Item::class, Folder::class, Account::class,
|
@Database(
|
||||||
ItemStateChange::class, ItemState::class], version = 3)
|
entities = [Feed::class, Item::class, Folder::class, Account::class,
|
||||||
|
ItemStateChange::class, ItemState::class], version = 4,
|
||||||
|
autoMigrations = [
|
||||||
|
AutoMigration(3, 4)
|
||||||
|
]
|
||||||
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class Database : RoomDatabase() {
|
abstract class Database : RoomDatabase() {
|
||||||
abstract fun feedDao(): FeedDao
|
abstract fun feedDao(): FeedDao
|
||||||
|
|
|
@ -36,52 +36,68 @@ interface NewItemStateDao : NewBaseDao<ItemState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
||||||
|
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId And starred = 1)""")
|
||||||
|
suspend fun setAllStarredItemsRead(accountId: Int)
|
||||||
|
|
||||||
|
//region all items read
|
||||||
|
|
||||||
suspend fun setAllItemsRead(accountId: Int) {
|
suspend fun setAllItemsRead(accountId: Int) {
|
||||||
setAllItemsReadByUpdate(accountId)
|
setAllItemsReadByUpdate(accountId)
|
||||||
//setAllItemsReadByInsert(accountId) //TODO use this after putting ItemState.remoteId UNIQUE?
|
setAllItemsReadByInsert(accountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
||||||
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId)""")
|
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId)""")
|
||||||
suspend fun setAllItemsReadByUpdate(accountId: Int)
|
suspend fun setAllItemsReadByUpdate(accountId: Int)
|
||||||
|
|
||||||
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id) Select 1 as read, 0 as starred,
|
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id, account_id) Select 1 as read, 0 as starred,
|
||||||
Item.remoteId From Item Inner Join Feed Where Feed.account_id = :accountId""")
|
Item.remoteId as remote_id, account_id From Item Inner Join Feed On Feed.id = Item.feed_id Where Feed.account_id = :accountId""")
|
||||||
suspend fun setAllItemsReadByInsert(accountId: Int)
|
suspend fun setAllItemsReadByInsert(accountId: Int)
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region read by feed
|
||||||
|
|
||||||
suspend fun setAllItemsReadByFeed(feedId: Int, accountId: Int) {
|
suspend fun setAllItemsReadByFeed(feedId: Int, accountId: Int) {
|
||||||
setAllItemsReadByFeedByUpdate(feedId, accountId)
|
setAllItemsReadByFeedByUpdate(feedId, accountId)
|
||||||
//setAllItemsReadByFeedByInsert(feedId, accountId) //TODO use this after putting ItemState.remoteId UNIQUE?
|
setAllItemsReadByFeedByInsert(feedId, accountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
||||||
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId and feed_id = :feedId)""")
|
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId and feed_id = :feedId)""")
|
||||||
suspend fun setAllItemsReadByFeedByUpdate(feedId: Int, accountId: Int)
|
suspend fun setAllItemsReadByFeedByUpdate(feedId: Int, accountId: Int)
|
||||||
|
|
||||||
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id) Select 1 as read, 0 as starred,
|
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id, account_id) Select 1 as read, 0 as starred,
|
||||||
Item.remoteId From Item Inner Join Feed Where Feed.account_id = :accountId And feed_id = :feedId""")
|
Item.remoteId As remote_id, account_id From Item Inner Join Feed Where Feed.account_id = :accountId
|
||||||
|
And feed_id = :feedId Group By Item.remoteId""")
|
||||||
suspend fun setAllItemsReadByFeedByInsert(feedId: Int, accountId: Int)
|
suspend fun setAllItemsReadByFeedByInsert(feedId: Int, accountId: Int)
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region read by folder
|
||||||
|
|
||||||
suspend fun setAllItemsReadByFolder(folderId: Int, accountId: Int) {
|
suspend fun setAllItemsReadByFolder(folderId: Int, accountId: Int) {
|
||||||
setAllItemsReadByFolderByUpdate(folderId, accountId)
|
setAllItemsReadByFolderByUpdate(folderId, accountId)
|
||||||
//setAllItemsReadByFolderByInsert(folderId, accountId) //TODO use this after putting ItemState.remoteId UNIQUE?
|
setAllItemsReadByFolderByInsert(folderId, accountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
||||||
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId and folder_id = :folderId)""")
|
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId and folder_id = :folderId)""")
|
||||||
suspend fun setAllItemsReadByFolderByUpdate(folderId: Int, accountId: Int)
|
suspend fun setAllItemsReadByFolderByUpdate(folderId: Int, accountId: Int)
|
||||||
|
|
||||||
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id) Select 1 as read, 0 as starred,
|
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id, account_id) Select 1 as read, 0 as starred,
|
||||||
Item.remoteId From Item Inner Join Feed Where Feed.account_id = :accountId And folder_id = :folderId""")
|
Item.remoteId As remote_id, account_id From Item Inner Join Feed On Feed.id = Item.feed_id
|
||||||
|
Where Feed.account_id = :accountId And folder_id = :folderId Group By Item.remoteId""")
|
||||||
suspend fun setAllItemsReadByFolderByInsert(folderId: Int, accountId: Int)
|
suspend fun setAllItemsReadByFolderByInsert(folderId: Int, accountId: Int)
|
||||||
|
|
||||||
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
//endregion
|
||||||
Inner Join Feed On Feed.id = Item.feed_id Where account_id = :accountId And starred = 1)""")
|
|
||||||
suspend fun setAllStarredItemsRead(accountId: Int)
|
//region news items read
|
||||||
|
|
||||||
suspend fun setAllNewItemsRead(accountId: Int) {
|
suspend fun setAllNewItemsRead(accountId: Int) {
|
||||||
setAllNewItemsReadByUpdate(accountId)
|
setAllNewItemsReadByUpdate(accountId)
|
||||||
//setAllItemsReadByInsert(accountId) //TODO use this after putting ItemState.remoteId UNIQUE?
|
setAllNewItemsReadByInsert(accountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
@Query("""Update ItemState set read = 1 Where remote_id In (Select Item.remoteId From Item
|
||||||
|
@ -90,9 +106,11 @@ interface NewItemStateDao : NewBaseDao<ItemState> {
|
||||||
Between DateTime(DateTime("now"), "-24 hour") And DateTime("now"))""")
|
Between DateTime(DateTime("now"), "-24 hour") And DateTime("now"))""")
|
||||||
suspend fun setAllNewItemsReadByUpdate(accountId: Int)
|
suspend fun setAllNewItemsReadByUpdate(accountId: Int)
|
||||||
|
|
||||||
@Query("""Insert Or Ignore Into ItemState(read, starred, remote_id) Select 1 as read, 0 as starred,
|
@Query("""Insert Into ItemState(read, starred, remote_id, account_id) Select 1 as read, 0 as starred,
|
||||||
Item.remoteId From Item Inner Join Feed Where Feed.account_id = :accountId
|
Item.remoteId As remote_id, account_id From Item Inner Join Feed On Feed.id = Item.feed_id
|
||||||
And DateTime(Round(Item.pub_date / 1000), 'unixepoch')
|
Where Feed.account_id = :accountId And DateTime(Round(Item.pub_date / 1000), 'unixepoch')
|
||||||
Between DateTime(DateTime("now"), "-24 hour") And DateTime("now")""")
|
Between DateTime(DateTime("now"), "-24 hour") And DateTime("now")""")
|
||||||
suspend fun setAllNewItemsReadByInsert(accountId: Int)
|
suspend fun setAllNewItemsReadByInsert(accountId: Int)
|
||||||
|
|
||||||
|
//endregion
|
||||||
}
|
}
|
|
@ -3,11 +3,16 @@ package com.readrops.db.entities
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Index
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import com.readrops.db.entities.account.Account
|
import com.readrops.db.entities.account.Account
|
||||||
|
|
||||||
@Entity(foreignKeys = [ForeignKey(entity = Account::class, parentColumns = ["id"],
|
@Entity(
|
||||||
childColumns = ["account_id"], onDelete = ForeignKey.CASCADE)])
|
foreignKeys = [ForeignKey(
|
||||||
|
entity = Account::class, parentColumns = ["id"],
|
||||||
|
childColumns = ["account_id"], onDelete = ForeignKey.CASCADE
|
||||||
|
)]
|
||||||
|
)
|
||||||
data class ItemStateChange(
|
data class ItemStateChange(
|
||||||
@PrimaryKey val id: Int = 0,
|
@PrimaryKey val id: Int = 0,
|
||||||
@ColumnInfo(name = "read_change") val readChange: Boolean = false,
|
@ColumnInfo(name = "read_change") val readChange: Boolean = false,
|
||||||
|
@ -15,8 +20,16 @@ data class ItemStateChange(
|
||||||
@ColumnInfo(name = "account_id") val accountId: Int,
|
@ColumnInfo(name = "account_id") val accountId: Int,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Entity(foreignKeys = [ForeignKey(entity = Account::class, parentColumns = ["id"],
|
@Entity(
|
||||||
childColumns = ["account_id"], onDelete = ForeignKey.CASCADE)])
|
foreignKeys = [ForeignKey(
|
||||||
|
entity = Account::class, parentColumns = ["id"],
|
||||||
|
childColumns = ["account_id"], onDelete = ForeignKey.CASCADE
|
||||||
|
)],
|
||||||
|
indices = [Index( // TODO check potential performance regression at insertion when synchronizing
|
||||||
|
value = ["remote_id", "account_id"],
|
||||||
|
unique = true
|
||||||
|
)]
|
||||||
|
)
|
||||||
data class ItemState(
|
data class ItemState(
|
||||||
@PrimaryKey(autoGenerate = true) val id: Int = 0,
|
@PrimaryKey(autoGenerate = true) val id: Int = 0,
|
||||||
val read: Boolean = false,
|
val read: Boolean = false,
|
||||||
|
|
Loading…
Reference in New Issue