{#- Context variables:
   - company: str (e.g., "ACME Bank")
   - industry: str (e.g., "fsi")
   - catalog: str (e.g., "acme_fsi_demo")
   - bundle_name: str (e.g., "acme-bank-fsi-demo")
   - app_name: str (e.g., "acme-bank-fsi-app")
   - warehouse_id: str
   - workspace_host: str
   - databricks_profile: str | None
   - lakebase_url: str | None
   - notification_email: str
-#}
# Command: /deploy

Deploy the {{ demo_title | lower }} to Databricks.

## Pre-flight Checks

Before deploying, validate everything:

```bash
# 1. Validate bundle configuration
databricks bundle validate

# 2. Run quality gates
uv run ruff check src/
uv run mypy src/
uv run pytest tests/ -v

# 3. Check progress
# Read docs/PROGRESS.md to confirm at least Wave 1 is completed
```

## Deployment Options

### Full Deployment (Lakehouse + App)
```bash
./scripts/deploy-all.sh [target]    # default target: dev
```
This runs lakehouse deployment first, then app deployment.

### Lakehouse Only (Data + Pipelines + ML)
```bash
./scripts/deploy-lakehouse.sh [target]
```
Deploys the asset bundle, runs data generation, DLT pipeline, and ML training (if applicable).

### App Only
```bash
./scripts/deploy-app.sh [target]
```
Builds the app, deploys via bundle, and configures service principal permissions.

## Post-deployment Validation

```bash
./scripts/validate.sh
```

## Troubleshooting

- **Bundle validation fails**: Check `databricks.yml` syntax and variable references. Run `databricks bundle validate` to see specific errors.
- **Job fails**: Run `python scripts/get_job_errors.py <RUN_ID>` to see task errors and failed SQL queries. Use `--json` for programmatic parsing.
- **Pipeline fails**: Check DLT SQL syntax and volume paths. Run `python scripts/get_job_errors.py <RUN_ID>` for details.
- **App deploy fails**: Check Lakebase connection and app.yaml configuration.
- **Permission errors**: Verify the service principal has CAN_USE on the SQL warehouse.
