mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-07 15:02:25 +00:00
* FEATURE: Tool name validation - Add unique index to the name column of the ai_tools table - correct our tests for AiToolController - tool_name field which will be used to represent to LLM - Add tool_name to Tools's presets - Add duplicate tools validation for AiPersona - Add unique constraint to the name column of the ai_tools table * DEV: Validate duplicate tool_name between builin tools and custom tools * lint * chore: fix linting * fix conlict mistakes * chore: correct icon class * chore: fix failed specs * Add max_length to tool_name * chore: correct the option name * lintings * fix lintings
24 lines
541 B
Ruby
24 lines
541 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddToolNameToAiTools < ActiveRecord::Migration[7.1]
|
|
def up
|
|
add_column :ai_tools,
|
|
:tool_name,
|
|
:string,
|
|
null: false,
|
|
limit: 100,
|
|
default: "",
|
|
if_not_exists: true
|
|
|
|
# Migrate existing name to tool_name
|
|
execute <<~SQL
|
|
UPDATE ai_tools
|
|
SET tool_name = regexp_replace(LOWER(name),'[^a-z0-9_]','', 'g');
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
remove_column :ai_tools, :tool_name, if_exists: true
|
|
end
|
|
end
|