diesel::table! {
    a2ui_messages (id) {
        id -> Integer,
        session_id -> Integer,
        message_id -> Integer,
        json -> Text,
        dismissed -> Bool,
    }
}

diesel::table! {
    messages (id) {
        id -> Integer,
        session_id -> Integer,
        user -> Bool,
        tool -> Bool,
        reasoning -> Nullable<Text>,
        reasoning_complete -> Bool,
        content -> Text,
        model_content -> Nullable<Text>,
        tool_approval_reasons -> Nullable<Text>,
        instruction_metadata -> Nullable<Text>,
        system -> Bool,
        compaction -> Bool,
        compaction_tail_start -> Nullable<Integer>,
        generation_duration_ms -> Nullable<Integer>,
        input_tokens -> Nullable<Integer>,
        cached_tokens -> Nullable<Integer>,
        output_tokens -> Nullable<Integer>,
    }
}

diesel::table! {
    projects (id) {
        id -> Integer,
        name -> Text,
        path -> Text,
        collapsed -> Bool,
    }
}

diesel::table! {
    sessions (id) {
        id -> Integer,
        project_id -> Integer,
        title -> Text,
        context_used -> Integer,
        context_limit -> Integer,
        last_tokens_per_second -> Nullable<Float>,
        state -> Text,
        compacted_summary -> Nullable<Text>,
        last_used -> BigInt,
        permission_mode -> Text,
    }
}

diesel::joinable!(sessions -> projects (project_id));
diesel::joinable!(a2ui_messages -> messages (message_id));
diesel::joinable!(a2ui_messages -> sessions (session_id));
diesel::joinable!(messages -> sessions (session_id));
diesel::allow_tables_to_appear_in_same_query!(a2ui_messages, messages, projects, sessions);
