-- ==========================================
-- Chat Switchboard — 021 Data Portability
-- ==========================================
-- v0.34.0: Indexes for data export and GDPR operations.
-- ==========================================

-- Partial index for batch message export (only non-deleted)
CREATE INDEX IF NOT EXISTS idx_messages_channel_active
    ON messages (channel_id, created_at)
    WHERE deleted_at IS NULL;

-- Index for user-scoped channel listing (export)
CREATE INDEX IF NOT EXISTS idx_channels_user_id
    ON channels (user_id);

-- Index for file lookup by user (export)
CREATE INDEX IF NOT EXISTS idx_files_user_id
    ON files (user_id);
