CREATE TABLE IF NOT EXISTS chat_history_sync
(
    id             TEXT    NOT NULL COLLATE NOCASE,
    account        TEXT    NOT NULL COLLATE NOCASE,
    component      TEXT COLLATE NOCASE,
    from_timestamp INTEGER NOT NULL,
    from_id        TEXT,
    to_timestamp   INTEGER NOT NULL
);

CREATE TABLE IF NOT EXISTS last_message_sync
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    account     TEXT NOT NULL COLLATE NOCASE,
    jid         TEXT NOT NULL COLLATE NOCASE,
    received_id TEXT,
    read_id     TEXT
);