Rename models and fields across all charts and dashboards in a project.
Renames models or fields in saved charts and dashboards, automatically updating all references.
lightdash rename [options]Options:
Required:
-t, --type <type> - [REQUIRED] Type of rename operation: model or field--from <from> - [REQUIRED] Current name to replace (lowercase + underscores only)--to <to> - [REQUIRED] New name (lowercase + underscores only)Conditional:
-m, --model <model> - Model name (required when --type field)Project Selection:
-p, --project <project uuid> - Project UUID (overrides active project)Execution Control:
-y, --assume-yes - Auto-confirm prompts (default: false)--dry-run - Test run without committing changes (default: false)--list - List all affected charts/dashboards (default: false)--verbose - Enable debug logging (default: false)Usage Examples:
# Rename a model
lightdash rename --type model --from customers --to dim_customers
# Rename a field in a model
lightdash rename --type field --model orders --from total --to total_amount
# Dry run to preview changes
lightdash rename --type model --from orders --to fact_orders --dry-run
# List affected charts and dashboards
lightdash rename --type field --model customers --from name --to customer_name --list
# Auto-confirm (non-interactive)
lightdash rename --type model --from products --to dim_products --assume-yes
# Rename in specific project
lightdash rename --type model --from orders --to fact_orders --project abc-123
# Rename with verbose output
lightdash rename --type model --from orders --to fact_orders --verboseRenames a dbt model across all charts and dashboards.
lightdash rename --type model --from <old_name> --to <new_name>What Gets Updated:
Chart Queries:
Dashboard Filters:
Saved Filters:
Example:
# Rename "orders" to "fact_orders"
lightdash rename --type model --from orders --to fact_ordersBefore:
metricQuery:
exploreName: orders
dimensions:
- orders_order_date
metrics:
- orders_total_revenueAfter:
metricQuery:
exploreName: fact_orders
dimensions:
- fact_orders_order_date
metrics:
- fact_orders_total_revenueRenames a field within a specific model.
lightdash rename --type field --model <model_name> --from <old_field> --to <new_field>What Gets Updated:
Chart Queries:
Dashboard Filters:
Chart Configurations:
Example:
# Rename "total" to "total_amount" in orders model
lightdash rename --type field --model orders --from total --to total_amountBefore:
metricQuery:
exploreName: orders
dimensions:
- orders_order_date
metrics:
- orders_total
sorts:
- fieldId: orders_total
descending: trueAfter:
metricQuery:
exploreName: orders
dimensions:
- orders_order_date
metrics:
- orders_total_amount
sorts:
- fieldId: orders_total_amount
descending: trueNames must follow strict validation:
Pattern: /^[a-z_]+$/
Valid characters:
Valid names:
# Good
lightdash rename --type model --from orders --to fact_orders
lightdash rename --type field --model customers --from name --to customer_name
lightdash rename --type model --from my_model --to my_new_modelInvalid names:
# Bad - uppercase
lightdash rename --type model --from Orders --to FactOrders
# Bad - hyphens
lightdash rename --type model --from orders --to fact-orders
# Bad - spaces
lightdash rename --type field --model customers --from "first name" --to "customer name"
# Bad - numbers anywhere (not allowed by validation pattern)
lightdash rename --type model --from orders --to orders_2024
# Bad - special characters
lightdash rename --type model --from orders --to orders!--from and --to names match patternOutput:
Searching for references to "orders"...
Found 25 charts using "orders"
Found 8 dashboards using "orders"
Total: 33 items to updateWith --list:
lightdash rename --type model --from orders --to fact_orders --listOutput:
Affected Charts:
- Monthly Revenue (monthly-revenue)
- Order Analysis (order-analysis)
- Customer Orders (customer-orders)
... (22 more)
Affected Dashboards:
- Executive Dashboard (executive-dashboard)
- Sales Overview (sales-overview)
... (6 more)With --dry-run:
lightdash rename --type model --from orders --to fact_orders --dry-runOutput:
DRY RUN - No changes will be committed
Would update 25 charts:
✓ Monthly Revenue
✓ Order Analysis
✓ Customer Orders
... (22 more)
Would update 8 dashboards:
✓ Executive Dashboard
✓ Sales Overview
... (6 more)
Total: 33 items would be updatedWithout --assume-yes:
Found 33 items to update.
This will modify:
- 25 charts
- 8 dashboards
Are you sure you want to rename "orders" to "fact_orders"? (y/N)With --assume-yes:
Output:
Renaming "orders" to "fact_orders"...
Updating charts... (25/25)
✓ Monthly Revenue
✓ Order Analysis
✓ Customer Orders
... (22 more)
Updating dashboards... (8/8)
✓ Executive Dashboard
✓ Sales Overview
... (6 more)
Successfully renamed "orders" to "fact_orders"
Updated 25 charts and 8 dashboardsTest rename without making changes:
lightdash rename --type model --from orders --to fact_orders --dry-runBehavior:
Use when:
Output shows:
Show affected content without details:
lightdash rename --type field --model customers --from name --to customer_name --listBehavior:
Use when:
Standardize model names:
# Apply naming convention: prefix with fact_ or dim_
lightdash rename --type model --from orders --to fact_orders
lightdash rename --type model --from customers --to dim_customers
lightdash rename --type model --from products --to dim_productsMake field names more descriptive:
# Improve field names
lightdash rename --type field --model orders --from total --to total_amount
lightdash rename --type field --model customers --from name --to customer_name
lightdash rename --type field --model orders --from date --to order_dateKeep Lightdash in sync with dbt changes:
# After renaming in dbt
# 1. Rename in dbt
# models/orders.sql → models/fact_orders.sql
# 2. Rename in Lightdash
lightdash rename --type model --from orders --to fact_orders
# 3. Redeploy
lightdash deploy --select fact_ordersUpdate after database schema changes:
# Database column renamed: customer_id → user_id
lightdash rename --type field --model customers --from customer_id --to user_idRemove outdated naming:
# Update old abbreviations
lightdash rename --type field --model orders --from cust_id --to customer_id
lightdash rename --type field --model orders --from amt --to amount# 1. List affected content
lightdash rename --type model --from orders --to fact_orders --list
# 2. Dry run to preview
lightdash rename --type model --from orders --to fact_orders --dry-run
# 3. Review impact
# (Check list of affected charts/dashboards)
# 4. Execute rename
lightdash rename --type model --from orders --to fact_orders
# 5. Validate results
lightdash validate --only charts dashboards
# 6. Test affected charts manuallyRename multiple items:
#!/bin/bash
# Script: refactor_models.sh
# Rename all models to follow convention
lightdash rename --type model --from orders --to fact_orders -y
lightdash rename --type model --from customers --to dim_customers -y
lightdash rename --type model --from products --to dim_products -y
# Validate after all renames
lightdash validate# 1. Rename in dbt
# Edit dbt files...
git add models/
git commit -m "Rename orders to fact_orders"
# 2. Rename in Lightdash (before deploying!)
lightdash rename --type model --from orders --to fact_orders
# 3. Deploy updated dbt models
lightdash deploy --select fact_orders
# 4. Validate
lightdash validate
# 5. Commit Lightdash changes (if using code management)
lightdash download --nested
git add lightdash/
git commit -m "Update Lightdash after model rename"name: Refactor Models
on:
workflow_dispatch:
inputs:
rename_type:
description: 'Type (model or field)'
required: true
from_name:
description: 'Current name'
required: true
to_name:
description: 'New name'
required: true
model_name:
description: 'Model name (if field rename)'
required: false
jobs:
rename:
runs-on: ubuntu-latest
steps:
- name: Install Lightdash CLI
run: npm install -g @lightdash/cli
- name: Rename
env:
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
CI: true
run: |
if [ "${{ github.event.inputs.rename_type }}" == "field" ]; then
lightdash rename \
--type field \
--model ${{ github.event.inputs.model_name }} \
--from ${{ github.event.inputs.from_name }} \
--to ${{ github.event.inputs.to_name }} \
--assume-yes
else
lightdash rename \
--type model \
--from ${{ github.event.inputs.from_name }} \
--to ${{ github.event.inputs.to_name }} \
--assume-yes
fi
- name: Validate
env:
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
CI: true
run: lightdash validate --only charts dashboardsError: "Invalid name format"
Error: Name must contain only lowercase letters and underscoresSolution:
/^[a-z_]+$/Error: "Model not found"
Error: Model "orders" not found in projectSolution:
Error: "Field not found"
Error: Field "total" not found in model "orders"Solution:
Error: "ForbiddenError"
ForbiddenError: You don't have permission to modify chartsSolution:
Error: "Target name already exists"
Error: Model "fact_orders" already existsSolution:
Without permissions:
Exit Code 0: Rename succeeded Exit Code 1: Rename failed
Success Output:
Renaming "orders" to "fact_orders"...
Updated 25 charts
Updated 8 dashboards
Successfully renamed "orders" to "fact_orders"Dry Run Output:
DRY RUN - No changes committed
Would update 25 charts
Would update 8 dashboards
Use without --dry-run to apply changes# 1. List affected items
lightdash rename --type model --from orders --to fact_orders --list
# 2. Count references
# (Check output count)
# 3. Assess risk
# - High usage = higher risk
# - Low usage = lower risk
# 4. Plan validation
# - Test affected charts
# - Validate dashboards
# - Check with usersFor models/fields used in many charts:
# 1. Communicate with team
# (Notify users of upcoming change)
# 2. Do dry run
lightdash rename --type model --from orders --to fact_orders --dry-run
# 3. Schedule during off-hours
# (Minimize disruption)
# 4. Execute rename
lightdash rename --type model --from orders --to fact_orders
# 5. Validate immediately
lightdash validate --only charts dashboards
# 6. Test critical charts
# (Manual testing)
# 7. Monitor for issues
# (Check for errors)# Test before executing
lightdash rename --type model --from orders --to fact_orders --dry-run# Check what will be affected
lightdash rename --type model --from orders --to fact_orders --list# Ensure nothing broke
lightdash rename --type model --from orders --to fact_orders
lightdash validate --only charts dashboards# Rename in Lightdash BEFORE deploying dbt changes
lightdash rename --type model --from orders --to fact_orders
lightdash deploy --select fact_orders# Test rename in preview environment
export LIGHTDASH_PROJECT="preview-uuid"
lightdash rename --type model --from orders --to fact_orders
lightdash validate --only charts
# If good, apply to production
export LIGHTDASH_PROJECT="prod-uuid"
lightdash rename --type model --from orders --to fact_orders# Keep changelog of renames
echo "$(date): Renamed orders to fact_orders" >> REFACTORING.log# Before major renames
# Post in team chat:
"🔄 Renaming 'orders' model to 'fact_orders' at 2pm
- 25 charts will be updated
- 8 dashboards will be updated
- All references will be automatically updated
- Please report any issues after 2pm"# Download current state
lightdash download --nested --path ./backup-$(date +%Y%m%d)
# Execute rename
lightdash rename --type model --from orders --to fact_orders
# If issues, can restore from backupIssue: Some references not updated
Error: Charts showing errors
lightdash validate --only chartsError: Dashboard filters not working
Issue: Rename taking too long