Database Migration
While your pipeline logic is dynamically discovered by the code, the Admin Dashboard requires the pipeline to be registered in the database to display it in the user interface.
Quick Summary
After generating your pipeline with make new-pipeline, simply run:
make migrateThat's it! The migration automatically:
Registers your pipeline across all organizations
Creates necessary components and presets
Sets up default configuration fields
Prepares everything for the Admin Dashboard
No modification needed unless you want to add custom configuration fields (which also requires creating a PresetConfig class).
Overview
When you use the make new-pipeline CLI tool, a migration file is automatically created for you in migration/versions/ with fully functional upgrade() and downgrade() functions. In most cases, you don't need to modify the generated migration file - it's ready to use as-is.
The generated migration handles:
Pipeline registration across all organizations (multi-tenancy support)
Component creation and linking
Preset creation with default configuration
Configuration fields and values setup
Catalog creation for prompt builders and language models
Chatbot application creation (for non-global pipelines)
Migration File Structure
The CLI tool generates a migration file with the following structure:
The file includes:
Proper Alembic revision tracking with 12-character hex revision ID
Auto-detected
down_revisionfrom the latest migrationFully implemented
upgrade()anddowngrade()functions - ready to use!Comprehensive pipeline setup for all organizations
Built-in multi-tenancy support
Default configuration fields with customization examples
Applying the Migration
The generated migration file is ready to use. Simply apply it:
This will:
Create the pipeline for all organizations in your system
Set up all required components and presets
Configure default settings
Create catalogs and chatbot applications
The migration is ready to use as-is! You don't need to modify it unless you want to add custom configuration fields.
When to Modify the Migration
In most cases, you don't need to modify the migration! The generated migration handles all standard pipeline setup automatically.
You only need to modify it if you want to add custom configuration fields that appear in the Admin Dashboard UI.
📘 Note: Adding custom fields requires two steps:
Add fields to the migration (this guide)
Create a PresetConfig class (Advanced Configuration Guide)
Adding Custom Configuration Fields
⚠️ Important: If you add custom configuration fields in the migration, you MUST also create a PresetConfig class in your pipeline. See the Advanced Configuration Guide for complete instructions.
The generated migration includes commented examples showing how to add custom config fields. To add custom fields:
Add fields to the migration file: Uncomment and modify the example code
Create a PresetConfig class: Define a Pydantic model with matching fields (see Advanced Configuration)
Run the migration:
make migrate
Both steps are required - the migration creates fields in the database, and PresetConfig provides type safety and validation in your code.
Example: Adding Custom Fields to Migration
After adding these fields to the migration, you must create a matching PresetConfig class. See the Advanced Configuration Guide - Preset Configuration section for complete examples of creating and registering PresetConfig classes.
Configuration Field Options
type
Data type of the field (must match PresetConfig type)
"string", "bool", "int", "float"
default_value
Default value as string (must match PresetConfig default)
"true", "0.7", "custom_value"
ui_type
UI component in Admin Dashboard
"text_field", "toggle", "number", "dropdown"
level
Configuration level
"PRESET_CHATBOT", "CHATBOT"
category_id
UI grouping category (optional)
Retrieved via get_config_category_id() or None
Important: Field names, types, and defaults in the migration must exactly match your PresetConfig class definition.
Configuration Categories (UI Grouping)
Configuration categories are used to group related fields in the Admin Dashboard UI. Fields with the same category_id will be displayed together in a collapsible section.
Available ConfigCategory options:
RETRIEVAL_KNOWLEDGE_CONFIGURATION: Groups retrieval and knowledge base settingsSEARCH_RETRIEVAL_BEHAVIOR: Groups search behavior and filtering optionsRESPONSE_GENERATION: Groups response generation settingsLANGUAGE_SETTINGS: Groups language and localization settings
If category_id is None: The field will be placed in an "Others" group in the Admin Dashboard.
Example:
Note: Custom fields will appear in the Admin Dashboard UI grouped by their category, allowing users to configure them per chatbot or preset.
Accessing Custom Fields in Pipeline Code
Once you've defined custom configuration fields in the migration and created the corresponding PresetConfig class (see Advanced Configuration), you can access them in your pipeline code through the pipeline_config parameter:
In the build() function:
In the build_initial_state() function:
The pipeline_config dictionary contains all configuration values set by users in the Admin Dashboard for the specific chatbot instance.
Troubleshooting
Multiple Heads Error
If you get a "Multiple heads" error when running migrations:
Solution: The CLI tool automatically detects the correct down_revision, but if you manually modified the migration, verify that the down_revision matches the latest migration's revision field in migration/versions/.
Migration Fails During Upgrade
If the migration fails during make migrate:
Check the error message: It usually indicates which step failed
Verify database state: Ensure your database is in a consistent state
Check for existing data: If the pipeline already exists, the migration may fail
Rollback if needed: Use
make downgrade1to rollback one migration step
Rollback command:
This will downgrade the most recent migration, executing its downgrade() function to remove the pipeline and related data.
Pipeline Not Visible in Admin Dashboard
If your pipeline doesn't appear after running the migration:
Verify migration ran successfully: Check the output of
make migrateCheck organization: Ensure you're viewing the correct organization
Restart the application: Sometimes a restart is needed to reload pipelines
Check database: Verify the pipeline exists in the
pipelinestable
Custom Config Fields Not Appearing
If your custom configuration fields don't show up in the Admin Dashboard:
Verify field definitions: Check that field types and UI types are valid
Check category assignment: Ensure the category ID is correct
Restart application: Config fields are cached on startup
Check database: Verify fields exist in
config_fieldstable
References
Last updated