Skip to main content

create_matrix_keys_schema

Function create_matrix_keys_schema 

Source
pub fn create_matrix_keys_schema(conn: &Connection) -> Result<()>
Expand description

Create every table/index this module needs — idempotent, called from crate::store::init_messenger_db right after create_matrix_schema, and directly by this module’s own tests.

Deviation from the plan’s literal DDL text (§2 second block, noted inline as -- DEVIATION): fallback_keys gains a key_id TEXT NOT NULL column. The plan’s own P2 CRUD contract (claim_one_time_key(...) -> Option<(key_id, key_json)>) must return a real key_id for a fallback-key claim exactly the way it already does for a real one-time-key claim (one_time_keys.key_id exists for that reason) — without this column the fallback branch would have no key_id to hand back to the claiming client. Only one fallback key is ever live per (user_id, device_id, algorithm) (that triple stays the primary key), so this is one extra scalar column, not a new dimension of the table.