DEV: Migrations shouldn't rely on the app (#253)
This commit is contained in:
parent
2ed5a40d7d
commit
b9d6179bfc
|
@ -2,24 +2,26 @@
|
||||||
|
|
||||||
class CreateAiTopicEmbeddingsTable < ActiveRecord::Migration[7.0]
|
class CreateAiTopicEmbeddingsTable < ActiveRecord::Migration[7.0]
|
||||||
def change
|
def change
|
||||||
truncation = DiscourseAi::Embeddings::Strategies::Truncation.new
|
create_table :ai_topic_embeddings_1_1, id: false do |t|
|
||||||
vector_reps =
|
t.integer :topic_id, null: false
|
||||||
[
|
t.integer :model_version, null: false
|
||||||
DiscourseAi::Embeddings::VectorRepresentations::AllMpnetBaseV2,
|
t.integer :strategy_version, null: false
|
||||||
DiscourseAi::Embeddings::VectorRepresentations::TextEmbeddingAda002,
|
t.text :digest, null: false
|
||||||
].map { |k| k.new(truncation) }
|
t.column :embeddings, "vector(768)", null: false
|
||||||
|
t.timestamps
|
||||||
|
|
||||||
vector_reps.each do |vector_rep|
|
t.index :topic_id, unique: true
|
||||||
create_table vector_rep.table_name.to_sym, id: false do |t|
|
end
|
||||||
t.integer :topic_id, null: false
|
|
||||||
t.integer :model_version, null: false
|
|
||||||
t.integer :strategy_version, null: false
|
|
||||||
t.text :digest, null: false
|
|
||||||
t.column :embeddings, "vector(#{vector_rep.dimensions})", null: false
|
|
||||||
t.timestamps
|
|
||||||
|
|
||||||
t.index :topic_id, unique: true
|
create_table :ai_topic_embeddings_2_1, id: false do |t|
|
||||||
end
|
t.integer :topic_id, null: false
|
||||||
|
t.integer :model_version, null: false
|
||||||
|
t.integer :strategy_version, null: false
|
||||||
|
t.text :digest, null: false
|
||||||
|
t.column :embeddings, "vector(1536)", null: false
|
||||||
|
t.timestamps
|
||||||
|
|
||||||
|
t.index :topic_id, unique: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,15 +2,12 @@
|
||||||
|
|
||||||
class CreateMultilingualTopicEmbeddingsTable < ActiveRecord::Migration[7.0]
|
class CreateMultilingualTopicEmbeddingsTable < ActiveRecord::Migration[7.0]
|
||||||
def change
|
def change
|
||||||
truncation = DiscourseAi::Embeddings::Strategies::Truncation.new
|
create_table :ai_topic_embeddings_3_1, id: false do |t|
|
||||||
vector_rep = DiscourseAi::Embeddings::VectorRepresentations::MultilingualE5Large.new(truncation)
|
|
||||||
|
|
||||||
create_table vector_rep.table_name.to_sym, id: false do |t|
|
|
||||||
t.integer :topic_id, null: false
|
t.integer :topic_id, null: false
|
||||||
t.integer :model_version, null: false
|
t.integer :model_version, null: false
|
||||||
t.integer :strategy_version, null: false
|
t.integer :strategy_version, null: false
|
||||||
t.text :digest, null: false
|
t.text :digest, null: false
|
||||||
t.column :embeddings, "vector(#{vector_rep.dimensions})", null: false
|
t.column :embeddings, "vector(1024)", null: false
|
||||||
t.timestamps
|
t.timestamps
|
||||||
|
|
||||||
t.index :topic_id, unique: true
|
t.index :topic_id, unique: true
|
||||||
|
|
|
@ -2,15 +2,12 @@
|
||||||
|
|
||||||
class CreateBgeTopicEmbeddingsTable < ActiveRecord::Migration[7.0]
|
class CreateBgeTopicEmbeddingsTable < ActiveRecord::Migration[7.0]
|
||||||
def change
|
def change
|
||||||
truncation = DiscourseAi::Embeddings::Strategies::Truncation.new
|
create_table :ai_topic_embeddings_4_1, id: false do |t|
|
||||||
vector_rep = DiscourseAi::Embeddings::VectorRepresentations::BgeLargeEn.new(truncation)
|
|
||||||
|
|
||||||
create_table vector_rep.table_name.to_sym, id: false do |t|
|
|
||||||
t.integer :topic_id, null: false
|
t.integer :topic_id, null: false
|
||||||
t.integer :model_version, null: false
|
t.integer :model_version, null: false
|
||||||
t.integer :strategy_version, null: false
|
t.integer :strategy_version, null: false
|
||||||
t.text :digest, null: false
|
t.text :digest, null: false
|
||||||
t.column :embeddings, "vector(#{vector_rep.dimensions})", null: false
|
t.column :embeddings, "vector(1024)", null: false
|
||||||
t.timestamps
|
t.timestamps
|
||||||
|
|
||||||
t.index :topic_id, unique: true
|
t.index :topic_id, unique: true
|
||||||
|
|
Loading…
Reference in New Issue