Deploying migrations locally
Every schema change to STOCK_RAW, REDBOOK_VEHICLES_RAW, or any other raw table goes through a versioned schemachange migration — never a direct ALTER TABLE. This page is the "how do I run one" runbook. For naming conventions, file structure, and how the two projects' scripts differ under the hood, see Migrations.
Prerequisites
- Prerequisites & setup done — your
snowflake-drive-staging-admin/-prod-adminSnow CLI connections work. schemachangeinstalled (pip install schemachange, or it's already in the venv from setup).
Migrations authenticate through your personal admin Snow CLI connection, not the dbt service-account key — you don't need DRIVE_STAGING_DBT_KEY_PATH exported for this.
Deploy via the script (recommended)
Each dbt project has a migrations/deploy-migrations.sh that dry-runs first, then prompts before applying. The two scripts must be run from different working directories:
# Stock — run from the dbt project root
cd src/stock/dbt
source venv/bin/activate
./migrations/deploy-migrations.sh staging
# Redbook — run from inside the migrations directory itself
cd src/redbook/dbt
source venv/bin/activate
cd migrations
./deploy-migrations.sh stagingRunning Redbook's script from src/redbook/dbt instead of src/redbook/dbt/migrations fails — it looks for *.sql files in the current directory.
The script:
- Runs
schemachange deploy --dry-runand shows you what would change. - Prompts
Deploy migrations to staging? (y/N)— nothing applies until you confirm. - Runs the real deploy, then prints the
schemachange rendercommand to check history.
Passing prod as the first argument deploys to production the same way, using DRIVE_PROD_ROLE_DBT and connection snowflake-drive-prod-admin automatically — the script picks role/connection from the environment argument, you don't set them separately.
Deploy via Makefile
make deploy-migrations-stock # stock, staging
make deploy-migrations-redbook # redbook, staging
make deploy-migrations-stock-prod # stock, production
make deploy-migrations-redbook-prod # redbook, productionThe stock targets work as-is. The redbook targets cd src/redbook/dbt and invoke ./migrations/deploy-migrations.sh from there — but redbook's script requires being run from inside migrations/ itself (see above), so make deploy-migrations-redbook/-redbook-prod currently fail. Use the manual Redbook invocation above instead until that's fixed.
Non-interactive deployment (CI/automation)
Pipe y into the script to skip the confirmation prompt:
cd src/stock/dbt && . venv/bin/activate && \
echo "y" | ./migrations/deploy-migrations.sh stagingSame pattern for Redbook, run from src/redbook/dbt/migrations instead.
Verify
schemachange render -f migrations # from src/stock/dbt
schemachange render -f . # from src/redbook/dbt/migrationsShows applied migration history from each project's own SCHEMACHANGE_HISTORY table.