Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 7515956

Browse files
committed
copy rag fragment embeddings created during deploy window
1 parent e2f439c commit 7515956

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

db/post_migrate/20250113171444_drop_old_embedding_tables.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# frozen_string_literal: true
22
class DropOldEmbeddingTables < ActiveRecord::Migration[7.2]
33
def up
4-
drop_table :ai_topic_embeddings
5-
drop_table :ai_post_embeddings
6-
drop_table :ai_document_fragment_embeddings
4+
# Copy rag embeddings created during deploy.
5+
execute <<~SQL
6+
INSERT INTO ai_document_fragments_embeddings (rag_document_fragment_id, model_id, model_version, strategy_id, strategy_version, digest, embeddings, created_at, updated_at)
7+
(
8+
SELECT ai_document_fragment_embeddings.*
9+
FROM ai_document_fragment_embeddings
10+
LEFT OUTER JOIN ai_document_fragments_embeddings ON ai_document_fragment_embeddings.rag_document_fragment_id = ai_document_fragments_embeddings.rag_document_fragment_id
11+
WHERE ai_document_fragments_embeddings.rag_document_fragment_id IS NULL
12+
)
13+
SQL
714

815
execute <<~SQL
916
DROP INDEX IF EXISTS ai_topic_embeddings_1_1_search_bit;
@@ -33,6 +40,10 @@ def up
3340
DROP INDEX IF EXISTS ai_document_fragment_embeddings_7_1_search_bit;
3441
DROP INDEX IF EXISTS ai_document_fragment_embeddings_8_1_search_bit;
3542
SQL
43+
44+
drop_table :ai_topic_embeddings
45+
drop_table :ai_post_embeddings
46+
drop_table :ai_document_fragment_embeddings
3647
end
3748

3849
def down

0 commit comments

Comments
 (0)