Skip to content

Commit b2cf55f

Browse files
fix the article
1 parent 363d850 commit b2cf55f

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

mintlify/tutorials/batch-change-with-database-group.mdx

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,62 @@ level: Intermediate
99
estimated_time: '20 mins'
1010
---
1111

12-
import TerminalDockerRunVolume from '/snippets/install/terminal-docker-run-volume.mdx';
12+
import PreparationWithSampleData from '/snippets/tutorials/preparation-with-sample-data.mdx';
1313

14-
Bytebase offers multiple features to simplify batch change management. In this tutorial, we will guide you on how to configure **Environment** and **Database Group** to batch change databases for various scenarios.
14+
Bytebase simplifies deploying changes across multiple databases simultaneously. This tutorial demonstrates how to use **Environments** and **Database Groups** to efficiently manage batch changes across your database fleet.
1515

1616
![database-group-banner](/content/docs/tutorials/batch-change-with-database-group/database-group-banner.webp)
1717

18-
## Preparation
18+
## Prerequisites
1919

20-
1. Make sure you have [Docker](https://www.docker.com/) installed, and if you don’t have important existing Bytebase data locally, you can start over from scratch by `rm -rf ~/.bytebase/data`.
21-
22-
1. **Environment** is a **Community Plan** feature and **Database group** is an **Pro Plan** feature, you need to have a valid license to enable it. You can request a trial license key from [here](https://www.bytebase.com/pricing).
20+
- **Environment**: Available in all plans
21+
- **Database Groups**: Requires Pro Plan or higher ([request trial](https://www.bytebase.com/pricing))
2322

2423
## Procedure
2524

26-
### Step 1 - Start Bytebase and prepare the environments
27-
28-
To demonstrate the batch change, we need to prepare some databases first.
25+
## Step 1 - Start Bytebase with sample data
2926

30-
1. Copy and paste the commands to start one Bytebase via Docker.
27+
<PreparationWithSampleData />
3128

32-
<TerminalDockerRunVolume />
29+
## Step 2 - Set up environments and databases
3330

34-
1. Regsiter an admin account and it will be granted the `workspace admin` role automatically.
35-
36-
1. Go to **Environments**, update the existing `Prod` environment to `ProdAsia` and then create two new environments `ProdEU` and `ProdNA`.
31+
1. Navigate to **Environments**. Rename `Prod` to `ProdAsia`, then create two new environments: `ProdEU` and `ProdNA`.
3732

3833
![bb-env-3prod](/content/docs/tutorials/batch-change-with-database-group/bb-env-3prod.webp)
3934

40-
### Step 2 - Create databases
41-
42-
1. Bytebase provides two sample PostgreSQL instances. Click `Select Project` on the top bar, and click **New Project** on the popup. Fill it with a name `batch project` and create **Create**.
35+
1. Click **Select Project** in the top bar, then **New Project**. Name it `Batch Change Project` and click **Create**.
4336

44-
1. Go into project `batch change`, click **Database > Databases** on the left side bar. There is no databases belonging to this project yet. Click **New DB**. To mimic the real-world scenario, firstly, create `demo-test` which should be created on sample test instance. An issue will be created automatically, click **Rollout**. After the issue is done, the database is created.
37+
1. In the new project, navigate to **Database > Databases** and click **+ New DB**. Create `demo-test` on the Test instance. Click **Rollout** when the issue appears.
4538

46-
![bb-new-project](/content/docs/tutorials/batch-change-with-database-group/bb-new-db-test.webp)
47-
48-
![bb-issue-test-done](/content/docs/tutorials/batch-change-with-database-group/bb-issue-test-done.webp)
49-
50-
1. In the same way, create `demo-prod-1` and `demo-prod-2` which should be created on `ProdAsia` environment. `demo-prod-3` and `demo-prod-4` should be created on `ProdEU` environment. `demo-prod-5` and `demo-prod-6` should be created on `ProdNA` environment.
39+
1. Similarly, create the following databases:
40+
- `demo-prod-1` and `demo-prod-2` on `ProdAsia`
41+
- `demo-prod-3` and `demo-prod-4` on `ProdEU`
42+
- `demo-prod-5` and `demo-prod-6` on `ProdNA`
5143

5244
![bb-prod-db](/content/docs/tutorials/batch-change-with-database-group/bb-prod-db.webp)
5345

54-
### Step 3 - Batch change by environment (Community Plan)
46+
## Step 3 - Execute batch changes by environment (All plans)
5547

56-
1. Go to **Databases > Database** in the project, select `demo-test` and `demo-prod-1`~`demo-prod-6` and click **Edit Schema**.
48+
1. Navigate to **CI/CD > Plans**, click **+ New Plan**, and select **Schema Change**.
5749

58-
![bb-edit-schema](/content/docs/tutorials/batch-change-with-database-group/bb-edit-schema.webp)
50+
1. Select all databases and click **Confirm**.
5951

60-
1. Fill in a SQL and click **Create**. You can see the pipeline has four stages - Test, ProdAsia, ProdEU, and ProdNA. You may select the stage and choose either rollout change to the current database or the current stage.
52+
1. Enter the following SQL, then click **Create** and **Ready for review**:
6153

6254
```SQL
6355
CREATE TABLE t2("id" INTEGER NOT NULL);
6456
```
6557

66-
![bb-to-rollout](/content/docs/tutorials/batch-change-with-database-group/bb-to-rollout.webp)
67-
![bb-half-rollout](/content/docs/tutorials/batch-change-with-database-group/bb-half-rollout.webp)
58+
1. The **Overview** and **Rollout** tabs display four stages: Test, ProdAsia, ProdEU, and ProdNA. You can deploy changes to individual databases or entire stages.
6859

69-
1. After all the databases are rolled out, you can see the issue is done.
60+
![overview-4-stages](/content/docs/tutorials/batch-change-with-database-group/bb-overview-4-stages.webp)
61+
![rollout-4-stages](/content/docs/tutorials/batch-change-with-database-group/bb-rollout-4-stages.webp)
7062

71-
![bb-complete-rollout](/content/docs/tutorials/batch-change-with-database-group/bb-complete-rollout.webp)
63+
1. Go to the **Rollout** tab and click **Run** in the Test stage to execute.
7264

73-
### Step 4 - Database group (Pro/Enterprise Plan)
65+
![rollout-half-complete](/content/docs/tutorials/batch-change-with-database-group/bb-rollout-half-complete.webp)
66+
67+
## Step 4 - Use database groups (Pro/Enterprise)
7468

7569
We need first to upgrade to Pro/Enterprise Plan to use Database Group.
7670

@@ -80,25 +74,30 @@ We need first to upgrade to Pro/Enterprise Plan to use Database Group.
8074

8175
![bb-subscription](/content/docs/tutorials/batch-change-with-database-group/bb-subscription.webp)
8276

83-
1. Go to **Database > Groups** in the project, click **New database group**, fill the fields as follows, when you scroll down, you will see there's an option **Multitennancy**, keep it unchecked for now and click **Save**.
77+
1. Navigate to **Database > Groups** in your project. Click **+ New database group** and configure:
8478

8579
- **Name:** `demo-prod-all`
8680
- **Condition:** `resource.database_name startsWith demo-prod`
8781

8882
![bb-groups](/content/docs/tutorials/batch-change-with-database-group/bb-groups.webp)
8983

90-
1. Go to **Database > Groups** in the project, click **Change > Edit Schema**.
91-
92-
![bb-group-change](/content/docs/tutorials/batch-change-with-database-group/bb-group-change.webp)
84+
1. Go to **CI/CD > Plans**, click **+ New Plan**, select **Schema Migration**. Switch to the **Database Group** tab, select `demo-prod-all`, and click **Confirm**.
9385

94-
1. You many see the six databases in three stages. Fill in the SQLs and click **Create**.
86+
1. Enter the following SQL, then click **Create** and **Ready for review**:
9587

9688
```SQL
9789
CREATE TABLE t3("id" INTEGER NOT NULL);
9890
```
9991

100-
![bb-issue-group-to-rollout](/content/docs/tutorials/batch-change-with-database-group/bb-issue-group-to-rollout.webp)
92+
1. The **Overview** and **Rollout** tabs now show 3 production stages. Click **Run** in the ProdAsia stage to execute.
93+
94+
![bb-overview-3-stages](/content/docs/tutorials/batch-change-with-database-group/bb-overview-3-stages.webp)
95+
![bb-rollout-3-stages](/content/docs/tutorials/batch-change-with-database-group/bb-rollout-3-stages.webp)
10196

10297
## Summary
10398

104-
Now you have learned how to configure environment and database group to run batch changes in Bytebase.
99+
You've learned how to:
100+
101+
- Group databases by environment for staged rollouts
102+
- Use Database Groups to target databases matching specific criteria
103+
- Execute batch changes across multiple databases efficiently

0 commit comments

Comments
 (0)