[Store] New databasescheme

This commit is contained in:
Christian Pauly 2019-08-07 08:36:48 +02:00
parent 3c365bb884
commit 83c127183b

View file

@ -699,73 +699,69 @@ class Store {
'UNIQUE(client))', 'UNIQUE(client))',
/// The database scheme for the Room class. /// The database scheme for the Room class.
"Rooms": 'CREATE TABLE IF NOT EXISTS Rooms(' + 'Rooms': 'CREATE TABLE IF NOT EXISTS Rooms(' +
'id TEXT PRIMARY KEY, ' + 'room_id TEXT PRIMARY KEY, ' +
'membership TEXT, ' + 'membership TEXT, ' +
'topic TEXT, ' +
'highlight_count INTEGER, ' + 'highlight_count INTEGER, ' +
'notification_count INTEGER, ' + 'notification_count INTEGER, ' +
'prev_batch TEXT, ' +
'joined_member_count INTEGER, ' + 'joined_member_count INTEGER, ' +
'invited_member_count INTEGER, ' + 'invited_member_count INTEGER, ' +
'heroes TEXT, ' +
'prev_batch TEXT, ' +
'avatar_url TEXT, ' +
'draft TEXT, ' +
'unread INTEGER, ' + // Timestamp of when the user has last read the chat
'fully_read TEXT, ' + // ID of the fully read marker event
'description TEXT, ' +
'canonical_alias TEXT, ' + // The address in the form: #roomname:homeserver.org
'direct_chat_matrix_id TEXT, ' + //If this room is a direct chat, this is the matrix ID of the user
'notification_settings TEXT, ' + // Must be one of [all, mention]
// Security rules
'guest_access TEXT, ' +
'history_visibility TEXT, ' +
'join_rules TEXT, ' +
// Power levels
'power_events_default INTEGER, ' +
'power_state_default INTEGER, ' +
'power_redact INTEGER, ' +
'power_invite INTEGER, ' +
'power_ban INTEGER, ' +
'power_kick INTEGER, ' +
'power_user_default INTEGER, ' +
// Power levels for events
'power_event_avatar INTEGER, ' +
'power_event_history_visibility INTEGER, ' +
'power_event_canonical_alias INTEGER, ' +
'power_event_aliases INTEGER, ' +
'power_event_name INTEGER, ' +
'power_event_power_levels INTEGER, ' +
'UNIQUE(id))', 'UNIQUE(id))',
/// The database scheme for the Event class. /// The users which can be used to generate a room name if the room does not have one.
"Events": 'CREATE TABLE IF NOT EXISTS Events(' + 'Heroes': 'CREATE TABLE IF NOT EXISTS Heroes(' +
'id TEXT PRIMARY KEY, ' + 'room_id TEXT PRIMARY KEY, ' +
'chat_id TEXT, ' + 'matrix_id TEXT, ' +
'UNIQUE(room_id,matrix_id))',
/// The database scheme for the TimelineEvent class.
'Events': 'CREATE TABLE IF NOT EXISTS Events(' +
'event_id TEXT PRIMARY KEY, ' +
'room_id TEXT, ' +
'origin_server_ts INTEGER, ' + 'origin_server_ts INTEGER, ' +
'sender TEXT, ' + 'sender TEXT, ' +
'state_key TEXT, ' +
'content_body TEXT, ' +
'type TEXT, ' + 'type TEXT, ' +
'content_json TEXT, ' + 'unsigned TEXT, ' +
'content TEXT, ' +
"status INTEGER, " + "status INTEGER, " +
'UNIQUE(id))', 'UNIQUE(id))',
/// The database scheme for the User class. /// The database scheme for room states.
"Users": 'CREATE TABLE IF NOT EXISTS Users(' + 'State': 'CREATE TABLE IF NOT EXISTS State(' +
'chat_id TEXT, ' + // The chat id of this membership 'event_id TEXT PRIMARY KEY, ' +
'matrix_id TEXT, ' + // The matrix id of this user 'room_id TEXT, ' +
'displayname TEXT, ' + 'origin_server_ts INTEGER, ' +
'avatar_url TEXT, ' + 'sender TEXT, ' +
'membership TEXT, ' + // The status of the membership. Must be one of [join, invite, ban, leave] 'state_key TEXT, ' +
'power_level INTEGER, ' + // The power level of this user. Must be in [0,..,100] 'unsigned TEXT, ' +
'UNIQUE(chat_id, matrix_id))', 'prev_content TEXT, ' +
'type TEXT, ' +
'content TEXT, ' +
'UNIQUE(room_id,state_key,type))',
/// The database scheme for room states.
'AccountData': 'CREATE TABLE IF NOT EXISTS AccountData(' +
'type TEXT PRIMARY KEY, ' +
'content TEXT, ' +
'UNIQUE(type))',
/// The database scheme for room states.
'RoomAccountData': 'CREATE TABLE IF NOT EXISTS RoomAccountData(' +
'type TEXT PRIMARY KEY, ' +
'room_id TEXT, ' +
'content TEXT, ' +
'UNIQUE(type,room_id))',
/// The database scheme for room states.
'Presence': 'CREATE TABLE IF NOT EXISTS Presence(' +
'type TEXT PRIMARY KEY, ' +
'sender TEXT, ' +
'content TEXT, ' +
'UNIQUE(sender))',
/// The database scheme for the NotificationsCache class. /// The database scheme for the NotificationsCache class.
"NotificationsCache": 'CREATE TABLE IF NOT EXISTS NotificationsCache(' + 'NotificationsCache': 'CREATE TABLE IF NOT EXISTS NotificationsCache(' +
'id int PRIMARY KEY, ' + 'id int PRIMARY KEY, ' +
'chat_id TEXT, ' + // The chat id 'chat_id TEXT, ' + // The chat id
'event_id TEXT, ' + // The matrix id of the Event 'event_id TEXT, ' + // The matrix id of the Event