Files
assistant-storefront/db/migrate/20250104200055_create_captain_tables.rb
Liang XJ 092fb2e083
Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
Initial commit: Add logistics and order_detail message types
- Add Logistics component with progress tracking
- Add OrderDetail component for order information
- Support data-driven steps and actions
- Add blue color scale to widget SCSS
- Fix node overflow and progress bar rendering issues
- Add English translations for dashboard components

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-26 11:16:56 +08:00

91 lines
2.8 KiB
Ruby

class CreateCaptainTables < ActiveRecord::Migration[7.0]
def up
# Post this migration, the 'vector' extension is mandatory to run the application.
# If the extension is not installed, the migration will raise an error.
setup_vector_extension
create_assistants
create_documents
create_assistant_responses
create_old_tables
end
def down
drop_table :captain_assistant_responses if table_exists?(:captain_assistant_responses)
drop_table :captain_documents if table_exists?(:captain_documents)
drop_table :captain_assistants if table_exists?(:captain_assistants)
drop_table :article_embeddings if table_exists?(:article_embeddings)
# We are not disabling the extension here because it might be
# used by other tables which are not part of this migration.
end
private
def setup_vector_extension
return if extension_enabled?('vector')
begin
enable_extension 'vector'
rescue ActiveRecord::StatementInvalid
raise StandardError, "Failed to enable 'vector' extension. Read more at https://chwt.app/v4/migration"
end
end
def create_assistants
create_table :captain_assistants do |t|
t.string :name, null: false
t.bigint :account_id, null: false
t.string :description
t.timestamps
end
add_index :captain_assistants, :account_id
add_index :captain_assistants, [:account_id, :name], unique: true
end
def create_documents
create_table :captain_documents do |t|
t.string :name, null: false
t.string :external_link, null: false
t.text :content
t.bigint :assistant_id, null: false
t.bigint :account_id, null: false
t.timestamps
end
add_index :captain_documents, :account_id
add_index :captain_documents, :assistant_id
add_index :captain_documents, [:assistant_id, :external_link], unique: true
end
def create_assistant_responses
create_table :captain_assistant_responses do |t|
t.string :question, null: false
t.text :answer, null: false
t.vector :embedding, limit: 1536
t.bigint :assistant_id, null: false
t.bigint :document_id
t.bigint :account_id, null: false
t.timestamps
end
add_index :captain_assistant_responses, :account_id
add_index :captain_assistant_responses, :assistant_id
add_index :captain_assistant_responses, :document_id
add_index :captain_assistant_responses, :embedding, using: :ivfflat, name: 'vector_idx_knowledge_entries_embedding', opclass: :vector_l2_ops
end
def create_old_tables
create_table :article_embeddings, if_not_exists: true do |t|
t.bigint :article_id, null: false
t.text :term, null: false
t.vector :embedding, limit: 1536
t.timestamps
end
add_index :article_embeddings, :embedding, if_not_exists: true, using: :ivfflat, opclass: :vector_l2_ops
end
end