// @generated by `cargo run --manifest-path rust/Cargo.toml -p syncular-codegen --`
// Source: migrations/*.sql

diesel::table! {
    sync_blob_cache (hash) {
        hash -> Text,
        size -> BigInt,
        mime_type -> Text,
        body -> Binary,
        encrypted -> Integer,
        key_id -> Nullable<Text>,
        cached_at -> BigInt,
        last_accessed_at -> BigInt,
    }
}

diesel::table! {
    sync_blob_outbox (id) {
        id -> Integer,
        hash -> Text,
        size -> BigInt,
        mime_type -> Text,
        body -> Binary,
        encrypted -> Integer,
        key_id -> Nullable<Text>,
        status -> Text,
        attempt_count -> Integer,
        error -> Nullable<Text>,
        created_at -> BigInt,
        updated_at -> BigInt,
        next_attempt_at -> BigInt,
    }
}

diesel::table! {
    sync_conflicts (id) {
        id -> Text,
        outbox_commit_id -> Text,
        client_commit_id -> Text,
        op_index -> Integer,
        result_status -> Text,
        message -> Text,
        code -> Nullable<Text>,
        server_version -> Nullable<BigInt>,
        server_row_json -> Nullable<Text>,
        created_at -> BigInt,
        resolved_at -> Nullable<BigInt>,
        resolution -> Nullable<Text>,
    }
}

diesel::table! {
    sync_crdt_checkpoints (seq) {
        seq -> Integer,
        partition_id -> Text,
        stream_id -> Text,
        app_table -> Text,
        row_id -> Text,
        field_name -> Text,
        checkpoint_id -> Text,
        covers_seq -> BigInt,
        actor_id -> Nullable<Text>,
        client_id -> Nullable<Text>,
        key_id -> Text,
        ciphertext -> Text,
        scopes -> Text,
        created_at -> BigInt,
        server_seq -> Nullable<BigInt>,
    }
}

diesel::table! {
    sync_crdt_documents (document_key) {
        document_key -> Text,
        app_table -> Text,
        row_id -> Text,
        field_name -> Text,
        state_column -> Text,
        sync_mode -> Text,
        state_base64 -> Nullable<Text>,
        state_vector_base64 -> Text,
        pending_updates -> BigInt,
        flushed_updates -> BigInt,
        acked_updates -> BigInt,
        log_updates -> BigInt,
        created_at -> BigInt,
        updated_at -> BigInt,
        compacted_at -> Nullable<BigInt>,
    }
}

diesel::table! {
    sync_crdt_update_log (id) {
        id -> Integer,
        document_key -> Text,
        app_table -> Text,
        row_id -> Text,
        field_name -> Text,
        update_id -> Text,
        client_commit_id -> Nullable<Text>,
        origin -> Text,
        status -> Text,
        update_base64 -> Text,
        state_vector_base64 -> Text,
        created_at -> BigInt,
        flushed_at -> Nullable<BigInt>,
        acked_at -> Nullable<BigInt>,
    }
}

diesel::table! {
    sync_crdt_updates (seq) {
        seq -> Integer,
        partition_id -> Text,
        stream_id -> Text,
        app_table -> Text,
        row_id -> Text,
        field_name -> Text,
        update_id -> Text,
        actor_id -> Nullable<Text>,
        client_id -> Nullable<Text>,
        key_id -> Text,
        ciphertext -> Text,
        scopes -> Text,
        created_at -> BigInt,
        server_seq -> Nullable<BigInt>,
    }
}

diesel::table! {
    sync_migrations (version) {
        version -> Text,
        name -> Text,
        checksum -> Text,
        applied_at -> BigInt,
    }
}

diesel::table! {
    sync_outbox_commits (id) {
        id -> Text,
        client_commit_id -> Text,
        status -> Text,
        operations_json -> Text,
        last_response_json -> Nullable<Text>,
        error -> Nullable<Text>,
        created_at -> BigInt,
        updated_at -> BigInt,
        attempt_count -> Integer,
        acked_commit_seq -> Nullable<BigInt>,
        schema_version -> Integer,
        next_attempt_at -> BigInt,
    }
}

diesel::table! {
    sync_subscription_state (state_id, subscription_id) {
        state_id -> Text,
        subscription_id -> Text,
        #[sql_name = "table"]
        table_name -> Text,
        scopes_json -> Text,
        params_json -> Text,
        cursor -> BigInt,
        bootstrap_state_json -> Nullable<Text>,
        status -> Text,
        created_at -> BigInt,
        updated_at -> BigInt,
    }
}

diesel::table! {
    sync_verified_roots (state_id, subscription_id) {
        state_id -> Text,
        subscription_id -> Text,
        partition_id -> Text,
        commit_seq -> BigInt,
        root -> Text,
        created_at -> BigInt,
        updated_at -> BigInt,
    }
}

diesel::table! {
    comments (id) {
        id -> Text,
        task_id -> Text,
        project_id -> Nullable<Text>,
        body -> Text,
        author_id -> Text,
        deleted -> Integer,
        server_version -> BigInt,
    }
}

diesel::table! {
    projects (id) {
        id -> Text,
        name -> Text,
        owner_id -> Text,
        archived -> Integer,
        server_version -> BigInt,
    }
}

diesel::table! {
    tasks (id) {
        id -> Text,
        title -> Text,
        completed -> Integer,
        user_id -> Text,
        project_id -> Nullable<Text>,
        server_version -> BigInt,
        image -> Nullable<Text>,
        title_yjs_state -> Nullable<Text>,
        description -> Nullable<Text>,
    }
}

diesel::table! {
    syncular_task_counts (user_id, completed) {
        user_id -> Text,
        completed -> Integer,
        task_count -> Integer,
    }
}

diesel::allow_tables_to_appear_in_same_query!(
    sync_blob_cache,
    sync_blob_outbox,
    sync_conflicts,
    sync_crdt_checkpoints,
    sync_crdt_documents,
    sync_crdt_update_log,
    sync_crdt_updates,
    sync_migrations,
    sync_outbox_commits,
    sync_subscription_state,
    sync_verified_roots,
    comments,
    projects,
    tasks,
    syncular_task_counts,
);
