Filterable fields on an index causes fatal error when collection insert happens
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3548319. -->
Reported by: [lpeabody](https://www.drupal.org/user/1137356)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When an index has a filterable field on it, it is correctly included in the collection insertion operation but when the collection is created the respective column is not added. This results in an error like so:</p>
<pre>lpeabody@pop-os-darter8:~/Projects/digitalpolygon/cwb-shine-site (chatbot)$ ddev drush sapi-i shinebot_content_index<br> [success] Found 105 items to index for ShineBot Content Index. Indexing all items.<br> [success] Indexing a maximum number of 105 items (50 items per batch run) for the index 'ShineBot Content Index'.<br>> [warning] pg_query_params(): Query failed: ERROR: column "node_type" of relation "amazee_ai_abcdef" does not exist<br>> LINE 1: ..., drupal_long_id, server_id, index_id, embedding, node_type)...<br>> ^ PostgresPgvectorClient.php:199<br>> [error] Drupal\ai_provider_amazeeio\Vdb\Postgres\Exception\InsertIntoCollectionException: ERROR: column "node_type" of relation "amazee_ai_abcdef" does not exist<br>> LINE 1: ..., drupal_long_id, server_id, index_id, embedding, node_type)..</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Add a filterable field on the index.<br>
Try to index the content.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>During createCollection and insertIntoCollection, ensure table schema is correct, or modify it if needed.</p>
<p>See <a href="https://git.drupalcode.org/project/ai_provider_amazeeio/-/blob/1.2.x/src/Vdb/Postgres/PostgresPgvectorClient.php?ref_type=heads#L113">https://git.drupalcode.org/project/ai_provider_amazeeio/-/blob/1.2.x/src/Vdb/Postgres/PostgresPgvectorClient.php?ref_type=heads#L113</a><br>
and <a href="https://git.drupalcode.org/project/ai_provider_amazeeio/-/blob/1.2.x/src/Vdb/Postgres/PostgresPgvectorClient.php?ref_type=heads#L188">https://git.drupalcode.org/project/ai_provider_amazeeio/-/blob/1.2.x/src/Vdb/Postgres/PostgresPgvectorClient.php?ref_type=heads#L188</a>.</p>
<p>Maybe there can be a "ensureSchema" method that gets added that ensures the table schema is created/updated with all native and extra fields from the index?</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue