-- User blocking table: prevents DM creation and messaging between users. -- blocker_id is the user who initiated the block. -- blocked_id is the user being blocked. CREATE TABLE IF NOT EXISTS user_blocks ( blocker_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, blocked_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, created_at TEXT NOT NULL DEFAULT (datetime('now')), PRIMARY KEY (blocker_id, blocked_id), CHECK (blocker_id != blocked_id) ); -- Index for efficient "is user X blocked by user Y" lookups (DM send path). CREATE INDEX IF NOT EXISTS idx_user_blocks_blocked ON user_blocks(blocked_id, blocker_id);