Files
redux-scraper/db/migrate/20250731035548_create_telegram_bot_logs.rb
2025-08-05 05:05:21 +00:00

43 lines
1.2 KiB
Ruby

# typed: true
class CreateTelegramBotLogs < ActiveRecord::Migration[7.2]
def change
create_table :telegram_bot_logs do |t|
# Telegram user information
t.bigint :telegram_user_id, null: false
t.string :telegram_username
t.string :telegram_first_name
t.string :telegram_last_name
t.bigint :telegram_chat_id, null: false
# Request metadata
t.timestamp :request_timestamp, null: false
t.string :status, null: false
t.text :error_message
# Performance metrics
t.float :fingerprint_computation_time
t.float :search_computation_time
t.integer :search_results_count, default: 0
# Response and image data
t.jsonb :response_data, default: {}
t.binary :processed_image_sha256
t.timestamps
# Indexes for performance
t.index :telegram_user_id
t.index :request_timestamp
t.index :search_results_count
t.index :processed_image_sha256
t.index %i[telegram_user_id request_timestamp]
end
# Foreign key constraint to BlobFile (sha256 field)
add_foreign_key :telegram_bot_logs,
:blob_files,
column: :processed_image_sha256,
primary_key: :sha256
end
end