Bytebase provides a powerful GUI for deploying schema migrations. This tutorial walks you through deploying schema changes with features such as SQL Review, rollout policies, custom approval, time scheduling, and more. 4-steps-graph Bytebase offers Community, Pro, and Enterprise plans. Higher plans unlock additional deployment capabilities. We will explore them progressively.

Features covered

Preparation

  1. Ensure Docker is running, then start the Bytebase container:
    docker run --rm --init \
      --name bytebase \
      --publish 8080:8080 --pull always \
      --volume ~/.bytebase/data:/var/opt/bytebase \
      bytebase/bytebase:latest
    
  2. After Bytebase starts, visit localhost:8080. Register an admin account, and it will be granted the workspace admin role automatically.
  3. During workspace setup, choose the built-in sample data. setup-built-in-sample-data

Level 1: Automatic rollout in the Test environment (All plans)

  1. In Workspace, go to Environments > Test, and set the rollout policy to Automatic. env-test-auto
  2. From the top-left project switcher, select Sample Project. Under the CI/CD section, click Plans, then + New Plan. Choose Schema Migration (DDL) and select the hr_test database. plan-db-test
  3. Using the Schema Editor, add a new column nickname to the employee table and click Confirm. plan-schema-editor-nickname
  4. Click Create, then click Ready for Review. plan-test-to-create plan-test-to-review
  5. The rollout executes automatically to the Test environment. The issue is marked as Done. plan-test-auto-rollout-done

Level 2: Manual rollout with SQL Review (All plans)

  1. In Workspace, go to Environments > Prod. Leave the rollout policy as the default Manual. We’ll add an SQL Review policy to the Prod environment. env-prod-sql-review
  2. Click SQL Review Policy to open SQL Review under the Environment > Prod. Select the Sample Template, which has 20 enabled rules. sql-review-sample
  3. Click Confirm to add the SQL Review policy to the Prod environment. sql-review-prod
  4. From the top-left project switcher, select Sample Project. Under the CI/CD section, click Plans, then + New Plan. Choose Schema Migration (DDL) and select the hr_prod database. plan-db-prod
  5. Using the Schema Editor, add a new column nickname to the employee table and click Confirm. plan-schema-editor-nickname
  6. Intentionally violate the NOT NULL rule. Click Create; SQL Review runs automatically and shows a warning for the Prod task. plan-to-review-warning
  7. Click the warning to view details. plan-to-review-warning-detail
  8. Fix the SQL by adding the NOT NULL constraint. Click Save to update the plan. SQL Review runs again and should pass. Click Ready for Review, then Confirm to submit the plan for approval. plan-to-review-pass
  9. The rollout is now ready to execute manually. plan-prod-to-rollout
  10. Click Rollout, then click Run. rollout-prod-to-run rollout-prod-to-run-detail
  11. After the rollout completes, the issue is marked as Done. plan-prod-manual-rollout-done

Level 3: Manual rollout with custom approval (Enterprise)

If you want the approval flow to be dynamic based on context, such as the type of SQL statements, follow this tutorial: Database Change with Risk-Based Approval Flow.

Summary

You have learned how to deploy schema migrations using Bytebase. Explore more advanced capabilities:
  • GitOps: Observe Git pushes and trigger schema migrations.
  • Batch changes: Change multiple databases in a single workflow.
Join our Discord channel to discuss.