5 Mins Quick Start
In this guide, you'll use Bytebase Test Suite
to get familiar with the product in the quickest way. This suite includes one Bytebase 2.8.0 instance and two MySQL 8.0.29 instances.
The task here is to add nickname
column to employee
table for both dev and prod environments.
Prerequisites
Before starting, make sure you have installed Docker.
Procedure
Step 1 - Deploy with sample datasets
- Start Docker.
- Open Terminal to run the command:
MacOS & Linux
Windows
When the Terminal shows the following message, the execution is successful.
Now you have three containers running in Docker:
- A Bytebase instance
- A MySQL instance for the Test environment
- A MySQL instance for the Prod environment
Each MySQL instance has a copy of the sample dataset in it. Itβs the dataset_small from open-source database employee
.
- Open Bytebase in localhost:5678, and you can see the following page in the browser.
- Create an admin account, and you are in the workspace.
Step 2 - Prepare the workspace
2.1 Set up environments
- Click Environments on the top bar and you will see Test and Prod environments. You can keep the default settings or adjust them based on your needs.
Prod environment requires manual rolling out while Test environment skips that.
2.2 Add instances
-
Click Instances on the top bar.
-
Click Add Instance on the instances page, and you will see Create Instance dialog box.
-
Fill the fields as follows:
- Choose MySQL
- Instance Name: Sample Instance Test
- Environment: Test
- Host or Socket: host.docker.internal
- Port: 3307
- Username: root
- Password: [empty]
-
Click Create, and the instance is created.
-
Roll down to the bottom, you can find a section showing Databases and Users from this instance.
-
Repeat the operation with another instance and:
- Choose MySQL
- Instance Name: Sample Instance Prod
- Environment: Prod
- Host or Socket: host.docker.internal
- Port: 3306
- Username: root
- Password: [empty]
Now, you have configured two instances for Test and Prod environment containing copies of the same sample dataset.
Step 3 - Add a column nickname
to the employee
table
3.1 Create a project
In Bytebase, Project is the unit to contain and manage databases. Therefore, before dealing with the sample databases, you need to transfer them into a project first.
- Click Projects > New Project , you will find Create Project dialog box.
- Fill in Project Name with
Employee
, Key with the randomly generated one, and select Mode as Standard. - The
Employee
project is created successfully and you are on its detail page.
- Choose Transfer DB to transfer in the two
Employee
databases from Test and Prod environment. Theyβre in the default project since they have not been transferred into any specific project yet.
Now you are ready to manage these two employee
databases in your project. Your next task is to add a column named nickname
to the employee
table.
3.2 Create an SQL issue to alter schema
- Go to
Employee
project page. - Click Alter Schema, you will find an Alter Schema dialog box.
- Choose Alter multiple databases, select Test > employee, Prod > employee, and click Next.
- An issue is created, and you will be navigated to the new issue page. On top of SQL box, You can find that the issue has a pipeline with two stages - Test and Prod. Test stage is active by default.
-
Fill the fields as follows:
- Title: "Alter Schema: Add a column nickname".
- SQL:"ALTER TABLE employee ADD nickname VARCHAR(255) ;".
- Description(option): "Add a column nickname".
- Assignee: [yourself]
-
Click Apply to other stages, the SQL will be applied to Prod as well.
-
Click Create, and you will see the SQL Advisor kicks off automatically β checks the SQL statements against various rules.
-
As the Test environment doesn't require manual rolling out, the SQL will be applied to the database on Test environment automatically after passing those advisor checks. Then you are waiting for rollout for the Prod environment.
3.3 Review the SQL issue
- Click Approve if everything is OK and the SQL will be applied to the database on Prod environment.
- Click Resolve issue, and the issue is Done.
Step 4 - Verify the change is applied
- Choose the two
employee
databases and view theemployee
tables, you will seenickname
column is added.