Logo
Explore Help
Sign In
discourse/discourse-ai
1
0
Fork 0
You've already forked discourse-ai
mirror of https://github.com/discourse/discourse-ai.git synced 2025-07-10 08:03:28 +00:00
Code Issues Packages Projects Releases Wiki Activity
discourse-ai/db/migrate/20241025135522_alter_ai_ids_to_bigint.rb

14 lines
383 B
Ruby
Raw Permalink Normal View History

DEV: Fix mismatched column types (#868) The primary key is usually a bigint column, but the foreign key columns are usually of integer type. This can lead to issues when joining these columns due to mismatched types and different value ranges. This was using a temporary plugin / test API to make tests pass, but it is safe to alter "ai_document_fragment_embeddings" and "rag_document_fragments" tables because they usually have less than 1M rows and migration is going to be fast. Depending on the size of the community, "classification_results" table may have more than 1M rows and the migration will lock the table for a longer time. However, classification runs in background jobs and they will be automatically retried if they fail due to the lock, which makes it acceptable.
2024-10-28 15:36:42 +02:00
# frozen_string_literal: true
class AlterAiIdsToBigint < ActiveRecord::Migration[7.1]
def up
change_column :ai_document_fragment_embeddings, :rag_document_fragment_id, :bigint
change_column :classification_results, :target_id, :bigint
change_column :rag_document_fragments, :target_id, :bigint
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 82ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API