Logo

dev-resources.site

for different kinds of informations.

🐣Your First Database Schema Change in 5 Minutes with Bytebase

Published at
1/18/2024
Categories
database
schema
postgressql
Author
adela_bytebase
Categories
3 categories in total
database
open
schema
open
postgressql
open
Author
14 person written this
adela_bytebase
open
🐣Your First Database Schema Change in 5 Minutes with Bytebase

In this tutorial, you'll use the sample databases Bytebase provides by default to get familiar with the product in the quickest way.

Step 1 - Run via Docker

  1. Install and start Docker.
  2. Open Terminal to run the command:
  docker run --init \
    --name bytebase \
    --publish 8080:8080 \
    --volume ~/.bytebase/data:/var/opt/bytebase \
    bytebase/bytebase:2.13.1
Enter fullscreen mode Exit fullscreen mode

When the Terminal shows the following message, the execution is successful.

β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•    β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—  β•šβ–ˆβ–ˆβ•”β•     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘      β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β•β•    β•šβ•β•      β•šβ•β•   β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•

  Version 2.13.1 has started on port 8080 πŸš€

Enter fullscreen mode Exit fullscreen mode

Now you have Bytebase running in Docker.

dk-bb-running

  1. Open Bytebase in localhost:8080, fill in the fields and click Create admin account. You'll be redirected to the workspace.

bb-register

  1. Follow the Quikstart guide on the bottom to click around or dismiss it by now. You can click your avatar on top right and click Quickstart on the dropdown menu to reopen it later.

bb-first-workspace

Step 2 - One Issue with Two Stages

  1. Click My Issues on the left sidebar, and click the issue SAM-101 which is created by default.

bb-my-issues

  1. The issue is waiting to rollout. There's a pipeline consisting of two stages:
    1. Test Stage: apply to database hr_test on Test Sample instance
    2. Prod Stage: apply to database hr_prod on Prod Sample instance

Test stage is active by default.

bb-issue-test

  1. Click Prod Stage to switch to it, and you will see the two stages share the same SQL but to different databases. You may also notice there's a warning sign for SQL review on the Prod stage. That's because when the issue is created, Bytebase will run task checks automatically. SQL review is one of them.

bb-issue-prod

  1. Click the warning sign to see the details. If you wonder why only Prod Stage has the warning sign, it's because by default SQL Review is only configured for Prod environment. You can click the Settings (gear) on the top right, and click Security & Policy > SQL Review to have a look.

bb-sql-review-not-null

Step 3 - Roll out on Test Stage

  1. Switch back to Test Stage and click Rollout. Click Rollout on the confirmation dialog.

bb-test-rollout

  1. When the SQL is applied, there will be a checkmark on the Test Stage. Click View change and you'll see the diff.

bb-issue-test-done

issue-snapshot-diff

Step 4 - Roll out on Prod Stage

There are two ways to roll out on Prod Stage regarding the SQL review result.

  1. If you are confident with the SQL, you can click Rollout directly. Check the Rollout anyway, and click Rollout on the confirmation dialog.

bb-issue-prod-anyway

  1. Another way is to edit the SQL. Click Edit on top of the SQL, and add the NOT NULL. It will look like this:
   ALTER TABLE employee ADD COLUMN IF NOT EXISTS email TEXT NOT NULL DEFAULT '';
Enter fullscreen mode Exit fullscreen mode

Click Save, the checks will be run again. This time the SQL review will pass and it will roll out automatically. The issue will become Done as well.

bb-issue-done

You may ask why it's rolling out automatically, it's because for Community Plan, the rollout policy is automatic if the SQL review passes. You may go to Environments to check.

bb-env-automatic

Next Step

Now you have successfully performed your first schema change in Bytebase. It's the core part of Bytebase. You can continue to dig deeper by following Deploy Schema Migration with Rollout Policy.

schema Article's
30 articles in total
Favicon
Schema Markup can boost your click-through rates by up to 30%?
Favicon
Custom schema specific Supabase Server Component clients in Grida Form workspace
Favicon
Zod for TypeScript Schema Validation: A Comprehensive Guide
Favicon
Database schema design of Splitwise application
Favicon
Validating JSON Schema with Fixed and User-Defined Keys in Python
Favicon
Using Zod's z.union: An Important Pitfall to Avoid
Favicon
Desvendando o Atlas: Gerencie Seus Esquemas de Banco de Dados com EstiloπŸš€
Favicon
Customize Schema with @extend_schema_view
Favicon
Hotel reservation Schema design (PostgreSQL)
Favicon
How to Insert Data into Specific Table of PostgreSQL Schemas with Node.js
Favicon
Typesafe Supabase Flutter Queries
Favicon
Using yup to build schema with value parsing and validation.
Favicon
Designing an Optimal Database Schema for a Followers-Following System in a Blog-Post App
Favicon
JobPosting from Schema.org
Favicon
Unlocking the Power of Mongoose Schemas: Enhancements for Better Data Handling
Favicon
Unraveling the Power of Schema Markup: Elevating Your Website's Visibility and Performance
Favicon
How to handle complex json schema
Favicon
Navigating Django Schemas with Ease: How Django-schema-viewer Helps Developers
Favicon
🐣Your First Database Schema Change in 5 Minutes with Bytebase
Favicon
Multiplos schemas no mesmo tΓ³pico Kafka na linha de comando
Favicon
How pgroll works under the hood
Favicon
Automating API Documentation: A Journey from TypeScript to OpenAPI and Schema Governence with Optic
Favicon
Master schema validation in TypeScript with Zod
Favicon
πŸš› Deploy Database Schema Migrations with Bytebase
Favicon
Random Data Generator Website
Favicon
Xata's JSON Column Type
Favicon
Introducing pgroll: Zero-downtime, Reversible, Schema Migrations for Postgres
Favicon
Designing Your Database Schema
Favicon
WHAT ARE THE TYPES OF SCHEMA MARKEUP?
Favicon
Iceberg Schema Evolution in Trino

Featured ones: