Skip to main content

create_matrix_schema

Function create_matrix_schema 

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

Create every table/index this module needs — idempotent (IF NOT EXISTS/INSERT OR IGNORE throughout), so it runs on every boot. Called from [init_messenger_db] and directly by this module’s own tests against a plain in-memory connection (no SQLCipher key needed for schema creation) — same split social_db::create_social_schema uses.

Deviation from the plan’s literal DDL text (§2, both noted inline as -- DEVIATION): account_data.room_id drops its REFERENCES rooms(id) — the manager’s own correction makes room_id NOT NULL DEFAULT '' for global account data, and '' never matches a real room id, so keeping the foreign key would make every global upsert fail once PRAGMA foreign_keys=ON is set (as [init_messenger_db] does). Creates (or brings up to date) every table of the server. Refuses a database written by a newer build and snapshots an older one first; see crate::schema_guard.